[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [collector/master] Added binary literals as cobertura only warns, but all the results are



commit f3b4636632e8aab7011c4507dfb23d0a654d9bdf
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date:   Fri Sep 30 11:58:27 2016 +0200

    Added binary literals as cobertura only warns, but all the results are
    computed correctly.
    Rather have more readable code.  Test tools will have to adapt.
---
 .../org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
index 57307d8..6d82fc6 100644
--- a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -356,8 +356,8 @@ public class SanitizedBridgesWriter extends CollecTorMain {
       byte[] secret = this.getSecretForMonth(month);
       System.arraycopy(secret, 50, hashInput, 22, 33);
       byte[] hashOutput = DigestUtils.sha256(hashInput);
-      int hashedPort = ((((hashOutput[0] & 0xFF) << 8)
-          | (hashOutput[1] & 0xFF)) >> 2) | 0xC000;
+      int hashedPort = ((((hashOutput[0] & 0b1111_1111) << 8)
+          | (hashOutput[1] & 0b1111_1111)) >> 2) | 0b1100_0000_0000_0000;
       return String.valueOf(hashedPort);
     } else {
       return "1";



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits