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

Use parentheses to avoid misreading boolean assignment from equality check

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Storage Engines
    • StorEng - Defined Pipeline

      WiredTiger uses this idiom in a few dozen places:

      did_work = yield == 0;

      In this case (taken from __log_wrlsn_server), we are setting did_work to true if yield is zero.

      But it is easy to misread this as an assignment of zero to both did_work and yield. This is an easy point of confusion because we frequently initialize multiple variables on the same line in a similar manner. 

      To help avoid this type of misreading, we should change this usage to:

      did_work = (yield == 0);
      

            Assignee:
            backlog-server-storage-engines [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            keith.smith@mongodb.com Keith Smith
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: