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

flags macros cast flags to unsigned values, hiding warnings.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.3, 3.7.1, WT3.1.0
    • Component/s: None
    • Labels:
    • Sprint:
      Storage 2017-11-13, Storage 2017-12-04, Storage 2017-12-18
    • Backport Requested:
      v3.6

      Description

      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?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              keith.bostic Keith Bostic
              Reporter:
              keith.bostic Keith Bostic
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: