[SERVER-29003] Expression 'i >= 0' is always true. Unsigned type value is always >= 0. mmap_windows.cpp 197 Created: 27/Apr/17  Updated: 30/Oct/23  Resolved: 08/Jun/17

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 3.5.9

Type: Bug Priority: Minor - P4
Reporter: Kelsey Schubert Assignee: Kim Tao
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-28570 Analysis of 'MongoDB' source code by ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Storage 2017-06-19
Participants:

 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.



 Comments   
Comment by Githook User [ 08/Jun/17 ]

Author:

{u'name': u'Kim Tao', u'email': u'kim.tao@mongodb.com'}

Message: SERVER-29003 Fix unsigned int warning
Branch: master
https://github.com/mongodb/mongo/commit/6f7fd7318d61bd145bb75a9a0a5d35387d2a6b9f

Generated at Thu Feb 08 04:19:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.