Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-7039

Stat64_to_stat macro expansion leads to bugs

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • None
    • CRT

    Description

      Current Stat64_to_stat macro leads to a nasty bug.
      The Macro expands to several lines, and Stat64_to_stat is used as:
      if (!ret)
      stat64_to_stat(&buf64, buf);

      so the first expanded line will be conditioned to if(!ret) but the rest of the macro will be unconditioned executed.

      The patch modifies:
      if (!ret)
      stat64_to_stat(&buf64, buf);

      to

      if (!ret)

      { stat64_to_stat(&buf64, buf); }

      Also adds a comment in the MACRO function.
      There are other potential alternatives, but does the code less readable.

      http://www.parashift.com/c++-faq/macros-with-multi-stmts.html

      Attachments

        1. macro2.patch
          1 kB
        2. macro3.patch
          0.6 kB
        3. macro4.patch
          0.6 kB

        Activity

          People

            ThFabba ThFabba
            vicmarcal vicmarcal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: