Add WT_RET_MSG_CHK macro to complete ERR/RET family symmetry

XMLWordPrintableJSON

    • Storage Engines, Storage Engines - Persistence
    • 633.758
    • SE Persistence backlog
    • None

      Issue Summary

      The WT_ERR_/WT_RET_ macro families are designed to be symmetric: every goto-err pattern has a direct-return counterpart. WT_ERR_MSG_CHK exists in src/include/error.h but the corresponding WT_RET_MSG_CHK is missing, creating an asymmetry in the macro family.

      Without WT_RET_MSG_CHK, callers in cleanup-free functions must hand-roll the conditional:

      if \(\(ret = fn\(\)\) \!= 0\)
          WT\_RET\_MSG\(session, ret, "failed to do X: %s", details\);
      

      This is more verbose and inconsistent with the CHK pattern established by WT_ERR_MSG_CHK.

      Context

      • The gap lives in src/include/error.h — WT_ERR_MSG_CHK is defined at lines 103-108, WT_RET_MSG at lines 139-146.
      • The complete WT_ERR_/WT_RET/WT_TRET* macro set has counterparts for every variant except this one.
      • No prior work or related tickets.

      Proposed Solution

      Add WT_RET_MSG_CHK immediately after WT_RET_MSG (line 146) in src/include/error.h:

      #define WT\_RET\_MSG\_CHK\(session, v, ...\)            
          do {                                           
              int *ret = \(v\);                           
              if \(*ret \!= 0\)                            
                  WT\_RET\_MSG\(session, \_\_ret, *VA\_ARGS*\); 
          } while \(0\)
      

      Key design note: uses a local __ret (not the function-level ret) because we return directly — there is no err: label to expose ret to.

      Definition of Done

      • Macro added to src/include/error.h with a header comment matching surrounding style.
      • dist/s_fast passes (linting + clang-format).
      • Build and ctest pass with no regressions.

            Assignee:
            Etienne Petrel
            Reporter:
            Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: