Avoid side effect in RHS operand (MISRA-C). Clarify intended logic.
Fix MISRA-C related warning.
Avoid side effect in RHS operand (MISRA-C). Clarify intended logic.
Fix MISRA-C related warning.
Fix MISRA-C related warning.
utACK bdd83dd Is this the only MISRA-C warning?
@Empact This is the only warning for this specific issue, but there are warnings for other issues – some of which might be worth addressing. I'll look into which ones :-)
As this is a change in critical consensus code, I don't think this is worth the risk, just to shut up a warning. (as far as I know this is not ub?)
@laanwj I agree in the general case that we shouldn't refactor consensus critical code just to shut up a warning, but this change is about making the author's intention clear. Making the intention clear is extra important in consensus critical code to avoid future mistakes. It is not obvious for the reader that the side effect here is intentional.
FWIW, I thought it was a mistake when I first read it :-)
Should I add an extra comment instead?
@laanwj Just to make the rationale clear – this is not UB :-)
FWIW, both clang++ -S -O and g++ -S -O generate the same assembly for the before/after code.
Some git history:
Satoshi introduced this code in 6ff5f718b6a67797b2b3bab8905d607ad216ee21 (2010). @petertodd added a clarifying comment in 214d45b6b9a4f25d7d8bd4e5443fa2bee485353a (2013):
commit 214d45b6b9a4f25d7d8bd4e5443fa2bee485353a
Author: Peter Todd <pete@petertodd.org>
Date: Sun Aug 25 12:37:07 2013 -0400
Document and test OP_RESERVED weirdness
Seems it was forgotten about when IsPushOnly() and the unittests were
written. A particular oddity is that OP_RESERVED doesn't count towards
the >201 opcode limit unlike every other named opcode.
diff --git a/src/script.cpp b/src/script.cpp
index 2df2e9f0d..a3aae42d2 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -327,6 +327,8 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
return false;
if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE)
return false;
+
+ // Note how OP_RESERVED does not count towards the opcode limit.
if (opcode > OP_16 && ++nOpCount > 201)
return false;
utACK bdd83ddbea03ce025e19fdb24e0bc120d0f8d8ae
<!--a722867cd34abeea1fadc8d60700f111-->
Gitian builds for commit e8ffec69f773e67ae82535afc87164eb8102f05e (master):
358605e223a4956623f41da6e44ec62f... bitcoin-0.16.99-aarch64-linux-gnu-debug.tar.gz19b750d8df1ea13d614a4bf22d5f5e7e... bitcoin-0.16.99-aarch64-linux-gnu.tar.gze77b6a8b38f9c2a298d4fa8870da9691... bitcoin-0.16.99-arm-linux-gnueabihf-debug.tar.gz5b785cf94cf9d2632c82433a95e2e28d... bitcoin-0.16.99-arm-linux-gnueabihf.tar.gz88951687b6c9faccae192580c0c8d203... bitcoin-0.16.99-i686-pc-linux-gnu-debug.tar.gz958d89530deea212b75755cc72af4583... bitcoin-0.16.99-i686-pc-linux-gnu.tar.gz4f07ae0309676a2aa77be85146038cbc... bitcoin-0.16.99-osx-unsigned.dmgeb0aa660bb8bd57d44141537161bdecb... bitcoin-0.16.99-osx64.tar.gz62d63bd9c57468149190e18ae29c2e5b... bitcoin-0.16.99-win32-debug.zip3062e8911e9310aa1faef00fcdf11520... bitcoin-0.16.99-win32-setup-unsigned.exe27701810378b583927afea230a7f2457... bitcoin-0.16.99-win32.zipb68b2e4d9d08c44cf867213380a016eb... bitcoin-0.16.99-win64-debug.zip01bd60768d16ea1bc0a689bebe1c8281... bitcoin-0.16.99-win64-setup-unsigned.exe21ab31ed8504f6190797d9acde10779c... bitcoin-0.16.99-win64.zip0c4379f4e015b3f09dcb1dc440e4d76c... bitcoin-0.16.99-x86_64-linux-gnu-debug.tar.gz1ccc038285f265d1fc71a23d40862d70... bitcoin-0.16.99-x86_64-linux-gnu.tar.gz7c208dbc4bd9c1c775e00fd864d85e38... bitcoin-0.16.99.tar.gz5951f1248c7d6b1a301859903aec5227... bitcoin-linux-0.17-res.ymle11564823cdbee7468a0fcf29b444175... bitcoin-linux-build.logbe775e40bbb4e2bc7ba1a5246532f567... bitcoin-osx-0.17-res.yml96bf0583d0f754e5e32a27024278228a... bitcoin-osx-build.logf5c6249287ff188c73f2a1ffe6cd9eb3... bitcoin-win-0.17-res.ymle8c65f90606f6c44ff0f33a2b2115af0... bitcoin-win-build.logGitian builds for commit 1c61ee541e75a31f830e99d90bef980942abd551 (master and this pull):
de031636b591192e1c0bd977ff99bcaa... bitcoin-0.16.99-aarch64-linux-gnu-debug.tar.gz2bd93e8fa62e7ba631e0cf57eb0e6923... bitcoin-0.16.99-aarch64-linux-gnu.tar.gz3663440c61881136afc82eb84d0fa87b... bitcoin-0.16.99-arm-linux-gnueabihf-debug.tar.gz2fa71e85b2ec531f2cf5e98cf756206c... bitcoin-0.16.99-arm-linux-gnueabihf.tar.gz485edba7d9ecbefaa2e87c49bc0c291b... bitcoin-0.16.99-i686-pc-linux-gnu-debug.tar.gz6ff37e741b55c9e1643c92b7d0997eb6... bitcoin-0.16.99-i686-pc-linux-gnu.tar.gz2d83a29e13a24a847eddb2e4a53661c8... bitcoin-0.16.99-osx-unsigned.dmg9bb4f1acd2c0c01d2672d09b42d80ea0... bitcoin-0.16.99-osx64.tar.gze31bd8c3380a3d101ecdd7219eb00f64... bitcoin-0.16.99-win32-debug.zipa5a945f27fd49bc9dab5fed7abab94c0... bitcoin-0.16.99-win32-setup-unsigned.exe7a6924f0e6311981a913997429deef11... bitcoin-0.16.99-win32.zipb0bcee627eca23f55795e375aab82676... bitcoin-0.16.99-win64-debug.zip372a2fc7c5de64deb83f84a96d6ffe36... bitcoin-0.16.99-win64-setup-unsigned.exe4b12160c29b64a573abd1c03039d06e3... bitcoin-0.16.99-win64.zip1b65fa3e2b5f8229fbaa4b064c7f86b0... bitcoin-0.16.99-x86_64-linux-gnu-debug.tar.gz3fa77c3fcd4e9b0fab9bdcf99b331c1f... bitcoin-0.16.99-x86_64-linux-gnu.tar.gzf92682a8b75e6e38995541f902646fc7... bitcoin-0.16.99.tar.gz4cd89f02d937ec8a9045627785205b59... bitcoin-linux-0.17-res.ymlec49cc665731d2aa055995ba1c7730bf... bitcoin-linux-build.log520b7d7adc17542aca9a37000973b6f6... bitcoin-osx-0.17-res.ymlaa9465a25e44a6651a8dd984e1ead355... bitcoin-osx-build.log5d9a3564fac4eedf4ce634a816cb6de6... bitcoin-win-0.17-res.yml95c2b0a4259a3ccf831176584597d8ad... bitcoin-win-build.logClosing, as there's disagreement whether to do this.