Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-3720

flags macros cast flags to unsigned values, hiding warnings.

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.6.3, 3.7.1, WT3.1.0
    • Affects Version/s: None
    • Component/s: None
    • Storage 2017-11-13, Storage 2017-12-04, Storage 2017-12-18
    • v3.6

      The F_XXX flags macros cast their arguments to (uint32_t), which will potentially hide errors where the flags constants are too large for the field in which they're being stored, that is, if we use F_SET to turn on a 64-bit flag in a 32-bit field, we won't get an error.

      Separately, there's been a related discussion about clang-tidy: the clang-tidy tool doesn't like bitwise operations on signed types. It's coming from CERT, I suspect. We could turn off those warnings, but to "fix" them means all of our flags have to be declared unsigned. In other words, this code gets complaints because flags are signed:

      WT_ERR(__wt_tree_walk_custom_skip(session, &ref,
          __wt_compact_page_skip, NULL, WT_READ_NO_GEN | WT_READ_WONT_NEED));

      I suggest we:

      • Change all of our hex flags to be declared with a trailing 'u' to force them to be unsigned
      • Remove the (uint32_t) casts from the flags macros
      • Remove the 64-bit variants of the flags macros, we no longer need them.

      alexander.gorrod, thoughts?

            keith.bostic@mongodb.com Keith Bostic (Inactive)
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            0 Vote for this issue
            3 Start watching this issue