DroidFish: Fixed compiler warnings.

This commit is contained in:
Peter Osterlund 2015-03-13 21:43:57 +01:00
parent 7ac35ae42b
commit ed6ebbd4ab
9 changed files with 27 additions and 14 deletions

View File

@ -81,9 +81,9 @@ public final class TreeLogger {
/** Get a logger object set up for analyzing a log file. */
public static final TreeLogger getAnalyzer(String filename) {
RandomAccessFile raf = null;
try {
TreeLogger log = new TreeLogger();
RandomAccessFile raf;
raf = new RandomAccessFile(filename, "rw");
log.fc = raf.getChannel();
long len = raf.length();
@ -95,6 +95,8 @@ public final class TreeLogger {
throw new RuntimeException();
} catch (IOException e) {
throw new RuntimeException();
} finally {
if (raf != null) try { raf.close(); } catch (IOException e) {}
}
}

View File

@ -268,6 +268,7 @@ public class ChessController {
}
}
pgn = out.toString();
sc.close();
}
// Parse tag section
@ -315,6 +316,7 @@ public class ChessController {
}
// Parse move text section
sc.close();
sc = new Scanner(pgn);
sc.useDelimiter("\\s+");
while (sc.hasNext()) {
@ -326,6 +328,7 @@ public class ChessController {
break;
game.processString(strMove);
}
sc.close();
}
public void setFENOrPGN(String fenPgn) throws ChessParseError {

View File

@ -705,6 +705,8 @@ public abstract class ChessBoard extends View {
else
s = "0";
break;
case NONE:
break;
}
if (s != null) {
Rect bounds = new Rect();

View File

@ -255,6 +255,8 @@ public class EditOptions extends Activity {
modified = true;
break;
}
case BUTTON:
break;
}
}
if (modified)

View File

@ -432,6 +432,9 @@ public class EditPGN extends ListActivity {
}
});
break;
case CANCEL:
case OK:
break;
}
setResult(RESULT_CANCELED);
finish();

View File

@ -303,15 +303,13 @@ public class LoadFEN extends ListActivity {
Pair<FenInfoResult, ArrayList<FenInfo>> p = fenFile.getFenInfo(this, progress);
if (p.first != FenInfoResult.OK) {
fensInFile = new ArrayList<FenInfo>();
switch (p.first) {
case OUT_OF_MEMORY:
if (p.first == FenInfoResult.OUT_OF_MEMORY) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), R.string.file_too_large,
Toast.LENGTH_SHORT).show();
}
});
break;
}
setResult(RESULT_CANCELED);
finish();

View File

@ -288,17 +288,19 @@ public class ExternalEngine extends UCIEngineBase {
if (to.exists())
to.delete();
to.createNewFile();
FileChannel inFC = null;
FileChannel outFC = null;
FileInputStream fis = null;
FileOutputStream fos = null;
try {
inFC = new FileInputStream(from).getChannel();
outFC = new FileOutputStream(to).getChannel();
fis = new FileInputStream(from);
FileChannel inFC = fis.getChannel();
fos = new FileOutputStream(to);
FileChannel outFC = fos.getChannel();
long cnt = outFC.transferFrom(inFC, 0, inFC.size());
if (cnt < inFC.size())
throw new IOException("File copy failed");
} finally {
if (inFC != null) { try { inFC.close(); } catch (IOException ex) {} }
if (outFC != null) { try { outFC.close(); } catch (IOException ex) {} }
if (fis != null) { try { fis.close(); } catch (IOException ex) {} }
if (fos != null) { try { fos.close(); } catch (IOException ex) {} }
to.setLastModified(from.lastModified());
}
return to.getAbsolutePath();

View File

@ -79,14 +79,14 @@ public class InternalStockFish extends ExternalEngine {
}
private final void writeCheckSum(File f, long checkSum) {
OutputStream os = null;
DataOutputStream dos = null;
try {
os = new FileOutputStream(f);
DataOutputStream dos = new DataOutputStream(os);
OutputStream os = new FileOutputStream(f);
dos = new DataOutputStream(os);
dos.writeLong(checkSum);
} catch (IOException e) {
} finally {
if (os != null) try { os.close(); } catch (IOException ex) {}
if (dos != null) try { dos.close(); } catch (IOException ex) {}
}
}

View File

@ -1089,6 +1089,7 @@ public class DroidChessController {
case SEARCH: s.thinking = true; break;
case PONDER: s.ponder = true; break;
case ANALYZE: s.analyzing = true; break;
case NONE: break;
}
} else {
if ((s.state == GameState.DRAW_REP) || (s.state == GameState.DRAW_50))