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.
p2p-segwit.py
. Is there some issue with this test script?
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:
02016-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.
This introduces binary changes in these serialization functions:
0void CDiskBlockIndex::SerializationOp<CDataStream, CSerActionSerialize>(CDataStream&, CSerActionSerialize, int, int)
1void CDiskBlockIndex::SerializationOp<CDataStream, CSerActionUnserialize>(CDataStream&, CSerActionUnserialize, int, int)
2void CDiskBlockIndex::SerializationOp<CSizeComputer, CSerActionSerialize>(CSizeComputer&, CSerActionSerialize, int, int)
3void CMerkleTx::SerializationOp<CDataStream, CSerActionSerialize>(CDataStream&, CSerActionSerialize, int, int)
4void CMerkleTx::SerializationOp<CDataStream, CSerActionUnserialize>(CDataStream&, CSerActionUnserialize, int, int)
5void CWalletTx::SerializationOp<CDataStream, CSerActionSerialize>(CDataStream&, CSerActionSerialize, int, int)
6void CWalletTx::SerializationOp<CDataStream, CSerActionUnserialize>(CDataStream&, CSerActionUnserialize, int, int)
Edit: and in contrast to #8658, these do not go away with -O2
nVersion
)…
There seems to be a small diff:
0319294c319294
1< 17d0f1: lea 0x2dd1b2(%rip),%rdi # 45a2aa <leveldb::Status::Status(leveldb::Status::Code, leveldb::Slice const&, leveldb::Slice const&)::__PRETTY_FUNCTION__+0xaa>
2---
3> 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:
0commit=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
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--) {
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;
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();
vSortedSize
?
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
?
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;
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.
I get same binaries for bedf9a7 besides this diff:
0commit=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
0317267c317267
1< 17aa0b: lea 0x25704b(%rip),%rsi # 3d1a5d <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0xfd>
2---
3> 17aa0b: lea 0x25705b(%rip),%rsi # 3d1a6d <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0x10d>
4317684c317684
5< 17b325: lea 0x256737(%rip),%rsi # 3d1a63 <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0x103>
6---
7> 17b325: lea 0x256747(%rip),%rsi # 3d1a73 <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0x113>
8317757c317757
9< 17b471: lea 0x2dc552(%rip),%rdi # 4579ca <leveldb::Status::Status(leveldb::Status::Code, leveldb::Slice const&, leveldb::Slice const&)::__PRETTY_FUNCTION__+0xaa>
10---
11> 17b471: lea 0x2565e5(%rip),%rdi # 3d1a5d <boost::recursive_mutex::lock()::__PRETTY_FUNCTION__+0xfd>
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.