Fix some issues flagged by Coverity static analysis

This commit is contained in:
Sean Owen 2014-04-22 22:20:58 +01:00
parent 391e85ea51
commit 4050f5c2f3
4 changed files with 11 additions and 3 deletions

View file

@ -146,7 +146,10 @@ public final class EncodeActivity extends Activity {
return;
}
File barcodeFile = new File(barcodesRoot, makeBarcodeFileName(contents) + ".png");
barcodeFile.delete();
if (!barcodeFile.delete()) {
Log.w(TAG, "Could not delete " + barcodeFile);
// continue anyway
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(barcodeFile);

View file

@ -55,8 +55,7 @@ public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,
} else if (result instanceof ProductParsedResult) {
ProductParsedResult productParsedResult = (ProductParsedResult) result;
String productID = productParsedResult.getProductID();
String normalizedProductID = productParsedResult.getNormalizedProductID();
SupplementalInfoRetriever productRetriever =
SupplementalInfoRetriever productRetriever =
new ProductResultInfoRetriever(textView, productID, historyManager, context);
productRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else if (result instanceof ISBNParsedResult) {

View file

@ -98,6 +98,9 @@ final class DecodedBitStreamParser {
}
private static int getInt(byte[] bytes, byte[] x) {
if (x.length == 0) {
throw new IllegalArgumentException();
}
int val = 0;
for (int i = 0; i < x.length; i++) {
val += getBit(x[i], bytes) << (x.length - i - 1);

View file

@ -305,6 +305,9 @@ final class MatrixUtil {
// Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit
// operations. We don't care if cofficients are positive or negative.
static int calculateBCHCode(int value, int poly) {
if (poly == 0) {
throw new IllegalArgumentException("0 polynomial");
}
// If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1
// from 13 to make it 12.
int msbSetInPoly = findMSBSet(poly);