@@ -154,6 +154,7 @@ namespace {
154154 ~ScopedLock () {
155155 pthread_mutex_unlock (mtx_);
156156 }
157+
157158 private:
158159 pthread_mutex_t * mtx_;
159160#else
@@ -164,6 +165,7 @@ namespace {
164165 ~ScopedLock () {
165166 ReleaseMutex (mtx_);
166167 }
168+
167169 private:
168170 HANDLE mtx_;
169171#endif
@@ -211,16 +213,10 @@ namespace {
211213 struct Attributes attribs = {};
212214
213215 bool CanUse (int perms) {
214- if ((mode & perms) != perms &&
215- (mode & (perms << 3 )) != (perms << 3 ) &&
216- (mode & (perms << 6 )) != (perms << 6 ))
217- return false ;
218- return true ;
216+ return (mode & (perms | (perms << 3 ) | (perms << 6 ))) != 0 ;
219217 }
220218 bool IsUnused () {
221- if (FS_S_ISDIR (mode))
222- return nlink == 1 ;
223- return nlink == 0 ;
219+ return nlink == (FS_S_ISDIR (mode) ? 1 : 0 );
224220 }
225221 void FillStat (struct fs_stat * buf) {
226222 memset (buf, ' \0 ' , sizeof (struct fs_stat ));
@@ -408,6 +404,7 @@ namespace {
408404 break ;
409405 } while (Next ());
410406 }
407+
411408 private:
412409 struct RegularINode * inode_;
413410 fs_off_t rangeIdx_;
@@ -810,7 +807,7 @@ namespace {
810807 Realloc (fs->fds , fs->fdCount , fs->fdCount - 1 );
811808 --fs->fdCount ;
812809 }
813- struct Fd * GetFd (struct FSInternal * fs, unsigned int fdNum) {
810+ struct Fd * GetFd (struct FSInternal * fs, int fdNum) {
814811 if (fs->fdCount == 0 )
815812 return NULL ;
816813 int low = 0 ;
@@ -942,11 +939,11 @@ namespace {
942939 return 0 ;
943940 }
944941 const char * GetLast (const char * path) {
945- int pathLen = strlen (path);
942+ size_t pathLen = strlen (path);
946943 char name[FS_NAME_MAX + 1 ];
947- int nameNdx = FS_NAME_MAX;
944+ uint8_t nameNdx = FS_NAME_MAX;
948945 name[nameNdx--] = ' \0 ' ;
949- int i = pathLen;
946+ size_t i = pathLen;
950947 while (path[i] == ' /' )
951948 --i;
952949 while (i >= 0 ) {
@@ -958,17 +955,17 @@ namespace {
958955 }
959956 const char * AbsolutePath (struct FSInternal * fs, const char * path) {
960957 char absPath[FS_PATH_MAX];
961- int absPathLen = 0 ;
958+ size_t absPathLen = 0 ;
962959 if (path[0 ] != ' /' ) {
963- int cwdPathLen = strlen (fs->cwd .path );
960+ size_t cwdPathLen = strlen (fs->cwd .path );
964961 if (cwdPathLen != 1 ) {
965962 memcpy (absPath, fs->cwd .path , cwdPathLen);
966963 absPath[cwdPathLen] = ' /' ;
967964 absPathLen = cwdPathLen + 1 ;
968965 } else absPath[absPathLen++] = ' /' ;
969966 }
970- int pathLen = strlen (path);
971- for (int i = 0 ; i != pathLen; ++i) {
967+ size_t pathLen = strlen (path);
968+ for (size_t i = 0 ; i != pathLen; ++i) {
972969 if (path[i] == ' /' ) {
973970 if (absPathLen != 0 &&
974971 absPath[absPathLen - 1 ] != ' /' )
0 commit comments