]> source.dussan.org Git - jgit.git/commitdiff
[errorprone] Remove unnecessary comparison 57/1176057/1
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 15 Sep 2023 09:44:09 +0000 (11:44 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 13 Feb 2024 12:50:48 +0000 (13:50 +0100)
Raised by errorprone:

org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitConfig.java:406: error:
[ComparisonOutOfRange] chars may have a value in the range 0 to 65535;
therefore, this comparison to 0 will always evaluate to true
if (ch >= 0 && ch < inUse.length) {
       ^
see https://errorprone.info/bugpattern/ComparisonOutOfRange

Change-Id: I9625aa7894a34dbffd77d39a40c6e285c86b56d5
(cherry picked from commit cf5ec856bda907c0537ce5a80246b9ab18195c8b)

org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitConfig.java

index 6a9b45b0652c7eac2db2d05c1f04fa05b135866e..f701a41d673ffa022eb7f43b6d7f3a50d7b220c4 100644 (file)
@@ -403,7 +403,7 @@ public class CommitConfig {
                        for (int i = 0; i < len; i++) {
                                char ch = line.charAt(i);
                                if (!Character.isWhitespace(ch)) {
-                                       if (ch >= 0 && ch < inUse.length) {
+                                       if (ch < inUse.length) {
                                                inUse[ch] = true;
                                        }
                                        break;