Issues in first-principles calculations for defects in semiconductors and oxides