cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Fix Coverity-flagged CASSANDRA-6230 issues
Date Wed, 19 Aug 2015 21:30:56 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 51bc7f87d -> 4cc2b67df


Fix Coverity-flagged CASSANDRA-6230 issues


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/4cc2b67d
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/4cc2b67d
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/4cc2b67d

Branch: refs/heads/cassandra-3.0
Commit: 4cc2b67df369bc3e9587b9e4864b8058ca78cdf7
Parents: 51bc7f8
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Aug 20 00:30:30 2015 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Aug 20 00:30:53 2015 +0300

----------------------------------------------------------------------
 src/java/org/apache/cassandra/config/DatabaseDescriptor.java | 2 +-
 src/java/org/apache/cassandra/hints/HintsWriter.java         | 7 ++++---
 src/java/org/apache/cassandra/hints/LegacyHintsMigrator.java | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4cc2b67d/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index b3bc4d2..01455ac 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -1527,7 +1527,7 @@ public class DatabaseDescriptor
 
     public static long getMaxHintsFileSize()
     {
-        return conf.max_hints_file_size_in_mb * 1024 * 1024;
+        return conf.max_hints_file_size_in_mb * 1024L * 1024L;
     }
 
     public static boolean isIncrementalBackupsEnabled()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4cc2b67d/src/java/org/apache/cassandra/hints/HintsWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hints/HintsWriter.java b/src/java/org/apache/cassandra/hints/HintsWriter.java
index 300d9cc..5cadd35 100644
--- a/src/java/org/apache/cassandra/hints/HintsWriter.java
+++ b/src/java/org/apache/cassandra/hints/HintsWriter.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.StandardOpenOption;
 import java.util.zip.CRC32;
@@ -98,7 +99,7 @@ final class HintsWriter implements AutoCloseable
         File checksumFile = new File(directory, descriptor.checksumFileName());
         try (OutputStream out = Files.newOutputStream(checksumFile.toPath()))
         {
-            out.write(Integer.toHexString((int) globalCRC.getValue()).getBytes());
+            out.write(Integer.toHexString((int) globalCRC.getValue()).getBytes(StandardCharsets.UTF_8));
         }
         catch (IOException e)
         {
@@ -255,7 +256,7 @@ final class HintsWriter implements AutoCloseable
 
         private void maybeFsync()
         {
-            if (position() >= lastSyncPosition + DatabaseDescriptor.getTrickleFsyncIntervalInKb()
* 1024)
+            if (position() >= lastSyncPosition + DatabaseDescriptor.getTrickleFsyncIntervalInKb()
* 1024L)
                 fsync();
         }
 
@@ -265,7 +266,7 @@ final class HintsWriter implements AutoCloseable
 
             // don't skip page cache for tiny files, on the assumption that if they are tiny,
the target node is probably
             // alive, and if so, the file will be closed and dispatched shortly (within a
minute), and the file will be dropped.
-            if (position >= DatabaseDescriptor.getTrickleFsyncIntervalInKb() * 1024)
+            if (position >= DatabaseDescriptor.getTrickleFsyncIntervalInKb() * 1024L)
                 CLibrary.trySkipCache(fd, 0, position - (position % PAGE_SIZE), file.getPath());
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4cc2b67d/src/java/org/apache/cassandra/hints/LegacyHintsMigrator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hints/LegacyHintsMigrator.java b/src/java/org/apache/cassandra/hints/LegacyHintsMigrator.java
index 082e307..196f184 100644
--- a/src/java/org/apache/cassandra/hints/LegacyHintsMigrator.java
+++ b/src/java/org/apache/cassandra/hints/LegacyHintsMigrator.java
@@ -71,7 +71,7 @@ public final class LegacyHintsMigrator
         int meanCellCount = legacyHintsTable.getMeanColumns();
         double meanPartitionSize = legacyHintsTable.getMeanPartitionSize();
 
-        if (meanCellCount != 0 || meanPartitionSize != 0)
+        if (meanCellCount != 0 && meanPartitionSize != 0)
         {
             int avgHintSize = (int) meanPartitionSize / meanCellCount;
             size = Math.max(2, Math.min(size, (512 << 10) / avgHintSize));


Mime
View raw message