Skip to content
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

Merged
merged 1 commit into from
Jul 31, 2017

Conversation

TheBlueMatt
Copy link

  • 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);
Copy link

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); ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@sipa
Copy link

sipa commented Jul 19, 2017

utACK 64b378c

@@ -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;

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.

Copy link

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.

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.

Copy link

@gmaxwell gmaxwell left a 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.

@sipa
Copy link

sipa commented Jul 21, 2017

Needs rebase; also see my comment on __get_cpuid not updating output parameters.

@TheBlueMatt
Copy link
Author

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));
Copy link

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.

Copy link
Author

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.
@sipa
Copy link

sipa commented Jul 31, 2017

ACK 0ec2a34 (ran the LevelDB unit tests)

@sipa sipa merged commit 0ec2a34 into bitcoin-core:bitcoin-fork Jul 31, 2017
sipa added a commit that referenced this pull request Jul 31, 2017
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
@maflcko
Copy link

maflcko commented Jul 31, 2017

@TheBlueMatt Low priority, but you might want to consider submitting this upstream as well.

laanwj added a commit to bitcoin/bitcoin that referenced this pull request Aug 2, 2017
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
sickpig pushed a commit to sickpig/BitcoinUnlimited that referenced this pull request Aug 17, 2017
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)
mempko pushed a commit to meritlabs/merit that referenced this pull request Sep 28, 2017
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
cculianu pushed a commit to cculianu/bitcoin-abc that referenced this pull request Oct 5, 2017
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
protonn pushed a commit to argentumproject/argentum that referenced this pull request Jan 11, 2018
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 6, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 6, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 6, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 7, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 8, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 12, 2019
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
@maflcko maflcko mentioned this pull request Nov 6, 2019
charlesrocket pushed a commit to AXErunners/axe that referenced this pull request Nov 30, 2019
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
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants