diff options
author | Jack Lloyd <[email protected]> | 2017-10-06 21:09:01 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-10-06 21:09:01 -0400 |
commit | 9e3dca25c7197c39a815ce39da670a4232212a45 (patch) | |
tree | 06282ebe4c88e0f840320cf8b8584eab8550fec2 /src/lib | |
parent | aff93b716eda9d10be9f02e4b436b672510ab179 (diff) |
Address some bool/int conversion warnings from Sonar
Nothing major but probably good to clean these up.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/asn1/der_enc.cpp | 2 | ||||
-rw-r--r-- | src/lib/block/idea/idea.cpp | 3 | ||||
-rw-r--r-- | src/lib/codec/hex/hex.cpp | 5 | ||||
-rw-r--r-- | src/lib/utils/donna128.h | 7 |
4 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/asn1/der_enc.cpp b/src/lib/asn1/der_enc.cpp index e791bce8c..28a9bbc9a 100644 --- a/src/lib/asn1/der_enc.cpp +++ b/src/lib/asn1/der_enc.cpp @@ -290,7 +290,7 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n, if(n == 0) return add_object(type_tag, class_tag, 0); - bool extra_zero = (n.bits() % 8 == 0); + const size_t extra_zero = (n.bits() % 8 == 0) ? 1 : 0; secure_vector<uint8_t> contents(extra_zero + n.bytes()); BigInt::encode(&contents[extra_zero], n); if(n < 0) diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp index 4795a126a..c0364b325 100644 --- a/src/lib/block/idea/idea.cpp +++ b/src/lib/block/idea/idea.cpp @@ -26,7 +26,8 @@ inline uint16_t mul(uint16_t x, uint16_t y) const uint32_t P_hi = P >> 16; const uint32_t P_lo = P & 0xFFFF; - const uint16_t r_1 = static_cast<uint16_t>((P_lo - P_hi) + (P_lo < P_hi)); + const uint16_t carry = (P_lo < P_hi); + const uint16_t r_1 = static_cast<uint16_t>((P_lo - P_hi) + carry); const uint16_t r_2 = 1 - x - y; return CT::select(Z_mask, r_1, r_2); diff --git a/src/lib/codec/hex/hex.cpp b/src/lib/codec/hex/hex.cpp index 8d8d3ff49..6bbd7c28e 100644 --- a/src/lib/codec/hex/hex.cpp +++ b/src/lib/codec/hex/hex.cpp @@ -114,7 +114,10 @@ size_t hex_decode(uint8_t output[], bad_char + "'"); } - *out_ptr |= bin << (top_nibble*4); + if(top_nibble) + *out_ptr |= bin << 4; + else + *out_ptr |= bin; top_nibble = !top_nibble; if(top_nibble) diff --git a/src/lib/utils/donna128.h b/src/lib/utils/donna128.h index 5d5b18695..53e0a085b 100644 --- a/src/lib/utils/donna128.h +++ b/src/lib/utils/donna128.h @@ -59,15 +59,18 @@ class donna128 final donna128& operator+=(const donna128& x) { l += x.l; - h += (l < x.l); h += x.h; + + const uint64_t carry = (l < x.l); + h += carry; return *this; } donna128& operator+=(uint64_t x) { l += x; - h += (l < x); + const uint64_t carry = (l < x); + h += carry; return *this; } |