Followup to #8105.
The current set of PRs made clang compile Wshadow clean. Compiling with gcc revealed new needed changes. gcc is more strict in warnings. This is non-Qt part. I do not have an environment to test gcc+Qt build now.
Followup to #8105.
The current set of PRs made clang compile Wshadow clean. Compiling with gcc revealed new needed changes. gcc is more strict in warnings. This is non-Qt part. I do not have an environment to test gcc+Qt build now.
Hmm, two failures in p2p-segwit.py. Is there some issue with this test script?
Travis fails reliably. Is the commit producing identical binaries?
This commit should produce same binaries, yes.
91 | @@ -92,7 +92,7 @@ class CBlock : public CBlockHeader 92 | ADD_SERIALIZE_METHODS; 93 | 94 | template <typename Stream, typename Operation> 95 | - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int _nVersion) { 96 | + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
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.
I think I figured this out, see #8658 (comment) and the comment below that.
This introduces binary changes in these serialization functions:
void CDiskBlockIndex::SerializationOp<CDataStream, CSerActionSerialize>(CDataStream&, CSerActionSerialize, int, int)
void CDiskBlockIndex::SerializationOp<CDataStream, CSerActionUnserialize>(CDataStream&, CSerActionUnserialize, int, int)
void CDiskBlockIndex::SerializationOp<CSizeComputer, CSerActionSerialize>(CSizeComputer&, CSerActionSerialize, int, int)
void CMerkleTx::SerializationOp<CDataStream, CSerActionSerialize>(CDataStream&, CSerActionSerialize, int, int)
void CMerkleTx::SerializationOp<CDataStream, CSerActionUnserialize>(CDataStream&, CSerActionUnserialize, int, int)
void CWalletTx::SerializationOp<CDataStream, CSerActionSerialize>(CDataStream&, CSerActionSerialize, int, int)
void CWalletTx::SerializationOp<CDataStream, CSerActionUnserialize>(CDataStream&, CSerActionUnserialize, int, int)
Edit: and in contrast to #8658, these do not go away with -O2
OK, rebased and removed problematic parts (all serialization related, nVersion)...
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.
@fanquake surely not...
JFYI: I'm now building with other gcc version and there are a few other warnings 8)
172 | @@ -173,9 +173,9 @@ unsigned int base_uint<BITS>::bits() const 173 | { 174 | for (int pos = WIDTH - 1; pos >= 0; pos--) { 175 | if (pn[pos]) { 176 | - for (int bits = 31; bits > 0; bits--) {
change _bits to nbits.
Will do.
Done
528 | + size_t _read = fread((void*)&vchBuf[pos], 1, readNow, src); 529 | + if (_read == 0) { 530 | throw std::ios_base::failure(feof(src) ? "CBufferedFile::Fill: end of file" : "CBufferedFile::Fill: fread failed"); 531 | } else { 532 | - nSrcPos += read; 533 | + nSrcPos += _read;
change _read to nBytes
Will do.
Done
Concept ACK when this is the last patch/pull with regard to Wshadow.
47 | @@ -48,14 +48,14 @@ class CMedianFilter 48 | 49 | T median() const 50 | { 51 | - int size = vSorted.size(); 52 | - assert(size > 0); 53 | - if (size & 1) // Odd number of elements 54 | + int _size = vSorted.size();
vecsize
vSortedSize ?
I like vSortedSize, will do.
292 | @@ -293,7 +293,7 @@ inline void SerializeTransaction(TxType& tx, Stream& s, Operation ser_action, in 293 | const bool fAllowWitness = !(nVersion & SERIALIZE_TRANSACTION_NO_WITNESS); 294 | 295 | READWRITE(*const_cast<int32_t*>(&tx.nVersion)); 296 | - unsigned char flags = 0; 297 | + unsigned char _flags = 0;
serializeFlags?
I like both.
279 | @@ -280,17 +280,17 @@ bool CWallet::LoadWatchOnly(const CScript &dest) 280 | bool CWallet::Unlock(const SecureString& strWalletPassphrase) 281 | { 282 | CCrypter crypter; 283 | - CKeyingMaterial vMasterKey; 284 | + CKeyingMaterial _vMasterKey;
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
That would be great and even better solution, yes. Will wait.
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.
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.
Rebased, updated.
It is now -Wshadow clean for both old gcc (tested on gcc version 4.8.3 20140627 [gcc-4_8-branch revision 212064](SUSE Linux)) and also on the ultimate gcc (gcc version 6.2.1 20160830 [gcc-6-branch revision 239856](SUSE Linux)). And of course stays clean on other systems I regularly test on.
@paveljanik Mind to cherry-pick fd5654c, so we don't have to open another pull?
I get same binaries for bedf9a7 besides this diff:
commit=bedf9a7 && 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
317267c317267
< 17aa0b: lea 0x25704b(%rip),%rsi # 3d1a5d <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0xfd>
---
> 17aa0b: lea 0x25705b(%rip),%rsi # 3d1a6d <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0x10d>
317684c317684
< 17b325: lea 0x256737(%rip),%rsi # 3d1a63 <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0x103>
---
> 17b325: lea 0x256747(%rip),%rsi # 3d1a73 <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0x113>
317757c317757
< 17b471: lea 0x2dc552(%rip),%rdi # 4579ca <leveldb::Status::Status(leveldb::Status::Code, leveldb::Slice const&, leveldb::Slice const&)::__PRETTY_FUNCTION__+0xaa>
---
> 17b471: lea 0x2565e5(%rip),%rdi # 3d1a5d <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0xfd>
@MarcoFalke I can, but Wladimir doesn't want it to be enabled by default...
utACK f14745d
Either the warning is enabled and people can fix the warnings when they write new code or there is no warning and we stop caring about it. There is no such thing as "disable the warnign by default and create refactoring pulls every other week to fix new occurences".
To conclude, I think this is ready for merge. If it turns out to cause problems in the near future, we disable it and call it done.
@MarcoFalke Agreed. We should merge this and then fix the remaining issues found by users who use other build environments/configurations.
Concept ACK
Working on needed rebase...
utACK ad1ae7ae2e90a29fcfaaddee2d5acd025de72cbe, 9de90bb gives same binaries for me besides some boost_pretty_functions.
utACK ad1ae7a
Checked that this, rebased on master, results in identical bitcoind executables. ACK ad1ae7a