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. */ /** Get a logger object set up for analyzing a log file. */
public static final TreeLogger getAnalyzer(String filename) { public static final TreeLogger getAnalyzer(String filename) {
RandomAccessFile raf = null;
try { try {
TreeLogger log = new TreeLogger(); TreeLogger log = new TreeLogger();
RandomAccessFile raf;
raf = new RandomAccessFile(filename, "rw"); raf = new RandomAccessFile(filename, "rw");
log.fc = raf.getChannel(); log.fc = raf.getChannel();
long len = raf.length(); long len = raf.length();
@@ -95,6 +95,8 @@ public final class TreeLogger {
throw new RuntimeException(); throw new RuntimeException();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(); 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(); pgn = out.toString();
sc.close();
} }
// Parse tag section // Parse tag section
@@ -315,6 +316,7 @@ public class ChessController {
} }
// Parse move text section // Parse move text section
sc.close();
sc = new Scanner(pgn); sc = new Scanner(pgn);
sc.useDelimiter("\\s+"); sc.useDelimiter("\\s+");
while (sc.hasNext()) { while (sc.hasNext()) {
@@ -326,6 +328,7 @@ public class ChessController {
break; break;
game.processString(strMove); game.processString(strMove);
} }
sc.close();
} }
public void setFENOrPGN(String fenPgn) throws ChessParseError { public void setFENOrPGN(String fenPgn) throws ChessParseError {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -79,14 +79,14 @@ public class InternalStockFish extends ExternalEngine {
} }
private final void writeCheckSum(File f, long checkSum) { private final void writeCheckSum(File f, long checkSum) {
OutputStream os = null; DataOutputStream dos = null;
try { try {
os = new FileOutputStream(f); OutputStream os = new FileOutputStream(f);
DataOutputStream dos = new DataOutputStream(os); dos = new DataOutputStream(os);
dos.writeLong(checkSum); dos.writeLong(checkSum);
} catch (IOException e) { } catch (IOException e) {
} finally { } 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 SEARCH: s.thinking = true; break;
case PONDER: s.ponder = true; break; case PONDER: s.ponder = true; break;
case ANALYZE: s.analyzing = true; break; case ANALYZE: s.analyzing = true; break;
case NONE: break;
} }
} else { } else {
if ((s.state == GameState.DRAW_REP) || (s.state == GameState.DRAW_50)) if ((s.state == GameState.DRAW_REP) || (s.state == GameState.DRAW_50))