-
Notifications
You must be signed in to change notification settings - Fork 37
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
Clean up compile-time warnings (gcc 7.1) #10
Conversation
TheBlueMatt
commented
Jul 12, 2017
- max_file_size was already a size_t, so return that.
- ecx was somehow being listed as used-uninitialized
db/memtable.cc
Outdated
@@ -101,7 +101,7 @@ void MemTable::Add(SequenceNumber s, ValueType type, | |||
p += 8; | |||
p = EncodeVarint32(p, val_size); | |||
memcpy(p, value.data(), val_size); | |||
assert((p + val_size) - buf == encoded_len); | |||
assert((p + val_size) - buf >= 0 && size_t((p + val_size) - buf) == encoded_len); |
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.
Alternative: assert(p + val_size == buf + encoded_len);
?
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.
OK
3a18f15
to
64b378c
Compare
utACK 64b378c |
port/port_posix_sse.cc
Outdated
@@ -54,7 +54,7 @@ static inline bool HaveSSE42() { | |||
__cpuid(cpu_info, 1); | |||
return (cpu_info[2] & (1 << 20)) != 0; | |||
#elif defined(__GNUC__) | |||
unsigned int eax, ebx, ecx, edx; | |||
unsigned int eax, ebx, ecx = 0, edx; | |||
__get_cpuid(1, &eax, &ebx, &ecx, &edx); | |||
return (ecx & (1 << 20)) != 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.
It's concerning if the compiler is emitting a use without init here, suggests that it may be miscompiling the code.
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.
__get_cpuid can fail if the function parameter isn't supported by the hardware (which won't be the case for any supported CPU), in which case it does not modify eax/ebx/ecx/edx.
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.
ah bingo. @TheBlueMatt see how the sse4 stuff in bitcoin master uses __get_cpuid. please do that.
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.
ACK but the use without init really deserves a triple check, e.g. that the flags on the asm aren't set wrong in a way that makes it unable to tell that the asm that macro expands to modifies memory.
Edit: With nit.
Needs rebase; also see my comment on __get_cpuid not updating output parameters. |
64b378c
to
50f24f1
Compare
OK, stripped out the cpuid check as it was fixed in #5 (though not in the same way that was fixed in Core, in the same way that I had done here, I dont think it matters so I'll let someone else change it if they want). |
db/memtable.cc
Outdated
@@ -101,7 +101,7 @@ void MemTable::Add(SequenceNumber s, ValueType type, | |||
p += 8; | |||
p = EncodeVarint32(p, val_size); | |||
memcpy(p, value.data(), val_size); | |||
assert((p + val_size) - buf == encoded_len); | |||
assert(size_t((p + val_size)) == encoded_len + size_t(buf)); |
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.
No need for any casts here I think; it's just pointer arithmetic now.
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, indeed, sorry, changed the ordering around to make it mroe clear.
* max_file_size was already a size_t, so return that.
50f24f1
to
0ec2a34
Compare
ACK 0ec2a34 (ran the LevelDB unit tests) |
0ec2a34 Clean up compile-time warnings (gcc 7.1) (Matt Corallo) Pull request description: * max_file_size was already a size_t, so return that. * ecx was somehow being listed as used-uninitialized Tree-SHA512: 6aeb9d6ce343d27c00338a379e6f359a6591e06fda978204133b9f81d817d99d4e4fcb7c851cf366276ef0171cfe77fa5765d836014dd6f213653ac53420d121
@TheBlueMatt Low priority, but you might want to consider submitting this upstream as well. |
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962ff0..c521b3ac6 (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields)
b13a68e Squashed 'src/leveldb/' changes from 196962ff0..c521b3ac6 (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
Summary: Includes: bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from Bitcoin-ABC#5 (Cory Fields) Removes many warnings on MacOSX of the form: In file included from leveldb/util/cache.cc:10: In file included from ./leveldb/port/port.h:14: In file included from ./leveldb/port/port_posix.h:47: ./leveldb/port/atomic_pointer.h:55:3: warning: 'OSMemoryBarrier' is deprecated: first deprecated in macOS 10.12 - Use std::atomic_thread_fence() from <atomic> instead [-Wdeprecated-declarations] OSMemoryBarrier(); ^ The bitcoin core patches have been included in BU already by sickpig. Test Plan: make check. Installed and running fine. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D584
Summary: Includes: bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Removes many warnings on MacOSX of the form: In file included from leveldb/util/cache.cc:10: In file included from ./leveldb/port/port.h:14: In file included from ./leveldb/port/port_posix.h:47: ./leveldb/port/atomic_pointer.h:55:3: warning: 'OSMemoryBarrier' is deprecated: first deprecated in macOS 10.12 - Use std::atomic_thread_fence() from <atomic> instead [-Wdeprecated-declarations] OSMemoryBarrier(); ^ The bitcoin core patches have been included in BU already by sickpig. Test Plan: make check. Installed and running fine. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D584
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962ff0..c521b3ac6 (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315