Evaluate __wt_verbose_multi_* macro arguments once

XMLWordPrintableJSON

    • Type: Technical Debt
    • Resolution: Fixed
    • Priority: Minor - P4
    • WT12.0.0, 8.2.0-rc0
    • Affects Version/s: None
    • Component/s: Concurrency
    • None
    • Storage Engines, Storage Engines - Foundations
    • None
    • 5

      We pass the expression multi_category in to our verbose_multi macros, but because it's a macro we evaluate the expression 3 separate times. clang-analyzer reports a warning for this as the ternary passed in as multi_category could evaluate to a two-category struct the first evaluation, but a one-category struct in the second. In the following code
      for (__v_idx = 0; __v_idx < multi_category.cnt; __v_idx++) { \ if (WT_VERBOSE_ISSET(session, multi_category.categories[__v_idx])) { \
       
      The first multi_category could return an array with two verbose categories, so __v_idx iterates up to index 1, while the second multi_category evaluates to an array length 1 and we access past the end of the array.

              Assignee:
              Andrew Morton
              Reporter:
              Andrew Morton
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: