Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29003

Expression 'i >= 0' is always true. Unsigned type value is always >= 0. mmap_windows.cpp 197

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 3.5.9
    • Storage
    • Fully Compatible
    • ALL
    • Storage 2017-06-19

    Description

      void* MemoryMappedFile::map(....) {
        ....
        size_t len = strlen(filename);
        for (size_t i = len - 1; i >= 0; i--) {            // <=
          if (filename[i] == '/' || filename[i] == '\\')
            break;
       
          if (filename[i] == ':')
            filename[i] = '_';
        }
        ....
      }
      

      A link to the source code on GitHub

      PVS-Studio warning: V547 Expression 'i >= 0' is always true. Unsigned type value is always >= 0. mmap_windows.cpp 197

      The conditional statement of the loop (i >= 0) should always be true, as the loop counter ( i ) is of unsigned type (size_t).

      This issue was originally reported in SERVER-28570.

      Attachments

        Issue Links

          Activity

            People

              kimberly.tao@mongodb.com Kim Tao
              kelsey.schubert@mongodb.com Kelsey T Schubert
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: