-
Notifications
You must be signed in to change notification settings - Fork 35.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not shadow variables (gcc set) #8808
Conversation
d7036e6
to
d7690b3
Compare
Hmm, two failures in |
Travis fails reliably. Is the commit producing identical binaries? |
This commit should produce same binaries, yes. |
src/primitives/block.h
Outdated
@@ -92,7 +92,7 @@ class CBlock : public CBlockHeader | |||
ADD_SERIALIZE_METHODS; | |||
|
|||
template <typename Stream, typename Operation> | |||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int _nVersion) { | |||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this particular change is causing my clang on OS X build to fail -rescan
with:
2016-09-26 19:53:08 ERROR: ReadBlockFromDisk: Deserialize or I/O error - ReadCompactSize(): size too large: unspecified iostream_category error at CBlockDiskPos(nFile=49, nPos=4208853)
So reverting it.
But do not ask me, why it is the cause... I do not know yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I figured this out, see #8658 (comment) and the comment below that.
This introduces binary changes in these serialization functions:
Edit: and in contrast to #8658, these do not go away with |
fca66b4
to
dd08dc7
Compare
OK, rebased and removed problematic parts (all serialization related, |
dd08dc7
to
416654b
Compare
Rebased. |
@MarcoFalke Marco, can you please test for the same binaries here? |
There seems to be a small diff: 319294c319294
< 17d0f1: lea 0x2dd1b2(%rip),%rdi # 45a2aa <leveldb::Status::Status(leveldb::Status::Code, leveldb::Slice const&, leveldb::Slice const&)::__PRETTY_FUNCTION__+0xaa>
---
> 17d0f1: lea 0x2dd1b1(%rip),%rdi # 45a2a9 <leveldb::Status::Status(leveldb::Status::Code, leveldb::Slice const&, leveldb::Slice const&)::__PRETTY_FUNCTION__+0xa9> used the following command: commit=416654b4bdcc9f91cf84d4e3c645826d62979c1d && git checkout bitcoin/master && git reset --hard HEAD && curl https://raw.githubusercontent.com/laanwj/bitcoin-maintainer-tools/6e4425587736144b067f67ad792d9ee904e74fd7/patches/stripbuildinfo.patch | patch -p 1 && make -j 2 && objdump -d -r -C --no-show-raw-insn src/bitcoind > /tmp/d_old && curl https://github.com/bitcoin/bitcoin/commit/"${commit}".diff | patch -p 1 && make -j 2 && objdump -d -r -C --no-show-raw-insn src/bitcoind > /tmp/d_new && diff /tmp/d_old /tmp/d_new | wc |
This seems unrelated. |
I haven't done the identical binary checking yet, but it looks like the difference could be here ? 170 (0xaa) vs 169 (0xa9) |
@fanquake surely not... |
JFYI: I'm now building with other gcc version and there are a few other warnings 8) |
@@ -173,9 +173,9 @@ unsigned int base_uint<BITS>::bits() const | |||
{ | |||
for (int pos = WIDTH - 1; pos >= 0; pos--) { | |||
if (pn[pos]) { | |||
for (int bits = 31; bits > 0; bits--) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change _bits to nbits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Concept ACK when this is the last patch/pull with regard to Wshadow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filling up locals with _ prefixes in big pieces of code is less good than using better names, and also incompatible with a common convention of using _prefixes for function parameters.
src/streams.h
Outdated
throw std::ios_base::failure(feof(src) ? "CBufferedFile::Fill: end of file" : "CBufferedFile::Fill: fread failed"); | ||
} else { | ||
nSrcPos += read; | ||
nSrcPos += _read; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change _read to nBytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/timedata.h
Outdated
int size = vSorted.size(); | ||
assert(size > 0); | ||
if (size & 1) // Odd number of elements | ||
int _size = vSorted.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vecsize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vSortedSize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like vSortedSize, will do.
src/primitives/transaction.h
Outdated
@@ -293,7 +293,7 @@ inline void SerializeTransaction(TxType& tx, Stream& s, Operation ser_action, in | |||
const bool fAllowWitness = !(nVersion & SERIALIZE_TRANSACTION_NO_WITNESS); | |||
|
|||
READWRITE(*const_cast<int32_t*>(&tx.nVersion)); | |||
unsigned char flags = 0; | |||
unsigned char _flags = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sflags (this was less obvious to me, but my suggestion and @sipa thought it was okay)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serializeFlags
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like both.
@@ -280,17 +280,17 @@ bool CWallet::LoadWatchOnly(const CScript &dest) | |||
bool CWallet::Unlock(const SecureString& strWalletPassphrase) | |||
{ | |||
CCrypter crypter; | |||
CKeyingMaterial vMasterKey; | |||
CKeyingMaterial _vMasterKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I believe changing the name of CCryptoKeyStore master key will, I think change only four lines. Might be good to get an opinion from someone who's worked more on this code? @TheBlueMatt @pstratem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be great and even better solution, yes. Will wait.
I checked each of the changes so far, they appear correct to me (+/- the suggestion I made about changing the name of the member vMasterKey that I asked for others input on). I didn't check that they resulted in the same code. |
416654b
to
bedf9a7
Compare
Rebased, updated. It is now |
@paveljanik Mind to cherry-pick fd5654c, so we don't have to open another pull? |
Followup to #8105.
The current set of PRs made
clang
compileWshadow
clean. Compiling withgcc
revealed new needed changes.gcc
is more strict in warnings. This is non-Qt part. I do not have an environment to testgcc
+Qt build now.