Skip to content

Merge master to develop#6544

Closed
kuny0707 wants to merge 4 commits intodevelopfrom
master
Closed

Merge master to develop#6544
kuny0707 wants to merge 4 commits intodevelopfrom
master

Conversation

@kuny0707
Copy link
Contributor

@kuny0707 kuny0707 commented Feb 4, 2026

What does this PR do?
Merge master to develop

byte[] s = Arrays.copyOfRange(sign, 32, 64);
byte v = sign[64];
if (v < 27) {
v += 27; //revId -> v

Check failure

Code scanning / CodeQL

Implicit narrowing conversion in compound assignment High

Implicit cast of source type int to narrower destination type
byte
.

Copilot Autofix

AI about 23 hours ago

In general, this issue is fixed by avoiding compound assignments that rely on implicit narrowing casts. Instead, perform arithmetic in an appropriate wider type and then explicitly cast to the narrower type once, making the intent clear and allowing easy review of whether the cast is safe.

For this specific case, we want to preserve the existing behavior—v remains a byte, and when v < 27 we add 27 to it. To remove the implicit narrowing, we can rewrite v += 27; into a normal assignment that does an explicit cast after the addition, e.g. v = (byte) (v + 27);. The addition still happens in int, but now the narrowing back to byte is explicit and no longer hidden inside the compound operator. No other lines or types need to change, and no new imports or methods are required.

Concretely, in crypto/src/main/java/org/tron/common/crypto/Rsv.java, modify the body of the if (v < 27) block (around line 22) to replace v += 27; with v = (byte) (v + 27);. This keeps functionality identical while resolving the CodeQL warning.

Suggested changeset 1
crypto/src/main/java/org/tron/common/crypto/Rsv.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/crypto/src/main/java/org/tron/common/crypto/Rsv.java b/crypto/src/main/java/org/tron/common/crypto/Rsv.java
--- a/crypto/src/main/java/org/tron/common/crypto/Rsv.java
+++ b/crypto/src/main/java/org/tron/common/crypto/Rsv.java
@@ -19,7 +19,7 @@
     byte[] s = Arrays.copyOfRange(sign, 32, 64);
     byte v = sign[64];
     if (v < 27) {
-      v += 27; //revId -> v
+      v = (byte) (v + 27); //revId -> v
     }
     return new Rsv(r, s, v);
   }
EOF
@@ -19,7 +19,7 @@
byte[] s = Arrays.copyOfRange(sign, 32, 64);
byte v = sign[64];
if (v < 27) {
v += 27; //revId -> v
v = (byte) (v + 27); //revId -> v
}
return new Rsv(r, s, v);
}
Copilot is powered by AI and may make mistakes. Always verify output.
@kuny0707 kuny0707 closed this Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants