Use parentheses to clarify intended precedence when using bitwise operations.
Use parentheses to clarify intended precedence when using bitwise operations #10527
pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:clarify-precedence changing 2 files +3 −3-
practicalswift commented at 7:36 PM on June 4, 2017: contributor
-
Use parentheses to clarify intended precedence when using bitwise operations 722e95c85a
- fanquake added the label Refactoring on Jun 5, 2017
-
benma commented at 8:17 AM on June 5, 2017: none
Sometimes bitwise precedences can be tricky, but those two instances you changed are very clear without the parens. I.e. confusing
!a | bas!(a | b)looks impossible to me, even if only due to the spacing.The second example has only two operands, so you can't even read it wrong (unless you meant to include
?, but the stuff following it are strings and not numbers). -
in src/crypto/aes.cpp:140 in 722e95c85a
136 | @@ -137,7 +137,7 @@ static int CBCDecrypt(const T& dec, const unsigned char iv[AES_BLOCKSIZE], const 137 | // If used, padding size is the value of the last decrypted byte. For 138 | // it to be valid, It must be between 1 and AES_BLOCKSIZE. 139 | padsize = *--out; 140 | - fail = !padsize | (padsize > AES_BLOCKSIZE); 141 | + fail = (!padsize) | (padsize > AES_BLOCKSIZE);
MarcoFalke commented at 1:41 PM on June 5, 2017:nack per @benma
practicalswift commented at 8:30 PM on June 5, 2017: contributorClosing due to NACK consensus :-)
practicalswift closed this on Jun 5, 2017practicalswift deleted the branch on Apr 10, 2021DrahtBot locked this on Aug 18, 2022ContributorsLabels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:15 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:15 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me