ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [1/3] ant git commit: false positives for null dereferences
Date Wed, 21 Dec 2016 09:32:30 GMT
Repository: ant
Updated Branches:
  refs/heads/1.9.x 6c8b3542f -> 85ff7bf69


false positives for null dereferences


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

Branch: refs/heads/1.9.x
Commit: e1f9674ab3f5daec3b500fc2614be1d9a2a9bfe2
Parents: 6c8b354
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Wed Dec 21 10:31:23 2016 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Wed Dec 21 10:31:23 2016 +0100

----------------------------------------------------------------------
 src/main/org/apache/tools/ant/UnknownElement.java       |  3 ++-
 .../org/apache/tools/ant/taskdefs/MacroInstance.java    | 12 +++++++++---
 src/main/org/apache/tools/zip/ZipFile.java              |  6 +++---
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/e1f9674a/src/main/org/apache/tools/ant/UnknownElement.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/UnknownElement.java b/src/main/org/apache/tools/ant/UnknownElement.java
index 88cd498..15770c2 100644
--- a/src/main/org/apache/tools/ant/UnknownElement.java
+++ b/src/main/org/apache/tools/ant/UnknownElement.java
@@ -646,7 +646,8 @@ public class UnknownElement extends Task {
             return false;
         }
         for (int i = 0; i < childrenSize; ++i) {
-            UnknownElement child = (UnknownElement) children.get(i);
+            // children cannot be null childrenSize would have been 0
+            UnknownElement child = (UnknownElement) children.get(i); //NOSONAR
             if (!child.similar(other.children.get(i))) {
                 return false;
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/e1f9674a/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java b/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
index 682ca12..9ffa9b2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
+++ b/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
@@ -197,9 +197,12 @@ public class MacroInstance extends Task implements DynamicAttribute,
TaskContain
                     }
                     break;
                 case STATE_EXPECT_NAME:
+                    // macroName cannot be null as this state is only
+                    // ever reached from STATE_EXPECT_BRACKET after it
+                    // has been set
                     if (ch == '}') {
                         state = STATE_NORMAL;
-                        String name = macroName.toString().toLowerCase(Locale.ENGLISH);
+                        String name = macroName.toString().toLowerCase(Locale.ENGLISH); //NOSONAR
                         String value = (String) macroMapping.get(name);
                         if (value == null) {
                             ret.append("@{");
@@ -210,7 +213,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain
                         }
                         macroName = null;
                     } else {
-                        macroName.append(ch);
+                        macroName.append(ch); //NOSONAR
                     }
                     break;
                 default:
@@ -224,8 +227,11 @@ public class MacroInstance extends Task implements DynamicAttribute,
TaskContain
                 ret.append('@');
                 break;
             case STATE_EXPECT_NAME:
+                // macroName cannot be null as this state is only
+                // ever reached from STATE_EXPECT_BRACKET after it
+                // has been set
                 ret.append("@{");
-                ret.append(macroName.toString());
+                ret.append(macroName.toString()); //NOSONAR
                 break;
             default:
                 break;

http://git-wip-us.apache.org/repos/asf/ant/blob/e1f9674a/src/main/org/apache/tools/zip/ZipFile.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/ZipFile.java b/src/main/org/apache/tools/zip/ZipFile.java
index 1be53cd..f963ceb 100644
--- a/src/main/org/apache/tools/zip/ZipFile.java
+++ b/src/main/org/apache/tools/zip/ZipFile.java
@@ -1038,12 +1038,12 @@ public class ZipFile implements Closeable {
         @Override
         public boolean equals(final Object other) {
             if (super.equals(other)) {
-                // super.equals would return false if other were not an Entry
+                // super.equals would return false if other were null or not an Entry
                 final Entry otherEntry = (Entry) other;
                 return offsetEntry.headerOffset
-                        == otherEntry.offsetEntry.headerOffset
+                        == otherEntry.offsetEntry.headerOffset //NOSONAR
                     && offsetEntry.dataOffset
-                        == otherEntry.offsetEntry.dataOffset;
+                        == otherEntry.offsetEntry.dataOffset; //NOSONAR
             }
             return false;
         }


Mime
View raw message