refactor, fuzz: Make 64-bit shift explicit #30017

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:240501-fix-shift changing 2 files +2 −7
  1. hebasto commented at 11:43 pm on May 1, 2024: member

    This PR fixes MSVC warning C4334 in the fuzzing code. Similar to #26252.

    All DisableSpecificWarnings dropped from fuzz.vcxproj as all remained are inherited from common.init.vcxproj.

    Required to simplify warning suppression porting to the CMake-based build system.

  2. refactor: Make 64-bit shift explicit
    This change fixes MSVC level-3 warning C4334.
    See: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4334
    
    All `DisableSpecificWarnings` dropped from `fuzz.vcxproj` as all
    remained are inherited from `common.init.vcxproj`.
    b50d127a77
  3. DrahtBot commented at 11:43 pm on May 1, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, sipsorcery

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  4. laanwj added the label Tests on May 2, 2024
  5. maflcko commented at 8:27 am on May 2, 2024: member
    utACK b50d127a7710d790c2ba4a08f01b832c2a0b1203
  6. hebasto commented at 8:50 am on May 2, 2024: member
  7. in src/test/fuzz/poolresource.cpp:68 in b50d127a77
    62@@ -63,9 +63,9 @@ class PoolResourceFuzzer
    63     {
    64         if (m_total_allocated > 0x1000000) return;
    65         size_t alignment_bits = m_provider.ConsumeIntegralInRange<size_t>(0, 7);
    66-        size_t alignment = 1 << alignment_bits;
    67+        size_t alignment = size_t{1} << alignment_bits;
    68         size_t size_bits = m_provider.ConsumeIntegralInRange<size_t>(0, 16 - alignment_bits);
    69-        size_t size = m_provider.ConsumeIntegralInRange<size_t>(1U << size_bits, (1U << (size_bits + 1)) - 1U) << alignment_bits;
    70+        size_t size = m_provider.ConsumeIntegralInRange<size_t>(size_t{1} << size_bits, (size_t{1} << (size_bits + 1)) - 1U) << alignment_bits;
    


    paplorinc commented at 10:30 am on May 2, 2024:
    was the 1U deliberately kept here?

    hebasto commented at 11:36 am on May 2, 2024:
    It causes no issues?

    paplorinc commented at 11:48 am on May 2, 2024:
    I don’t have MSVC to test, just seemed suspicious. If it was deliberate, please resolve this comment.

    hebasto commented at 12:07 pm on May 2, 2024:

    I don’t have MSVC to test, just seemed suspicious.

    Do you mind elaborating your concerns?

    If it was deliberate, please resolve this comment.

    The MSVC warning C4334 is caused by the type of the left-hand side operand in the << operator. This PR is focused on resolving only this issue. I can’t see reasons to introduce unrelated code modifications.


    paplorinc commented at 12:46 pm on May 2, 2024:

    Do you mind elaborating your concerns?

    Looked like it’s still on the LHS of a shift ((size_bits + 1)) - 1U) << alignment_bits), but it’s not, no concerns, thanks for checking.

  8. sipsorcery commented at 7:56 pm on May 2, 2024: member
    utACK b50d127a7710d790c2ba4a08f01b832c2a0b1203
  9. fanquake merged this on May 3, 2024
  10. fanquake closed this on May 3, 2024

  11. hebasto deleted the branch on May 3, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-06-29 04:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me