فهرست منبع

Fixed up some bugs that clang's static analysis reported.

Ryan C. Gordon 14 سال پیش
والد
کامیت
9d11b991bc
3فایلهای تغییر یافته به همراه11 افزوده شده و 10 حذف شده
  1. 8 5
      src/archiver_qpak.c
  2. 1 1
      src/archiver_unpacked.c
  3. 2 4
      src/physfs.c

+ 8 - 5
src/archiver_qpak.c

@@ -525,19 +525,22 @@ static int QPAK_stat(dvoid *opaque, const char *filename, int *exists,
     const QPAKinfo *info = (const QPAKinfo *) opaque;
     const QPAKentry *entry = qpak_find_entry(info, filename, &isDir);
 
-    *exists = ((isDir) || (entry != NULL));
-    if (!exists)
-        return 0;
-
     if (isDir)
     {
+        *exists = 1;
         stat->filetype = PHYSFS_FILETYPE_DIRECTORY;
         stat->filesize = 0;
     } /* if */
-    else
+    else if (entry != NULL)
     {
+        *exists = 1;
         stat->filetype = PHYSFS_FILETYPE_REGULAR;
         stat->filesize = entry->size;
+    } /* else if */
+    else
+    {
+        *exists = 0;
+        return 0;
     } /* else */
 
     stat->modtime = -1;

+ 1 - 1
src/archiver_unpacked.c

@@ -216,7 +216,7 @@ PHYSFS_Io *UNPK_openRead(dvoid *opaque, const char *fnm, int *fileExists)
 {
     PHYSFS_Io *retval = NULL;
     UNPKinfo *info = (UNPKinfo *) opaque;
-    UNPKfileinfo *finfo;
+    UNPKfileinfo *finfo = NULL;
     UNPKentry *entry;
 
     entry = findEntry(info, fnm);

+ 2 - 4
src/physfs.c

@@ -394,11 +394,10 @@ static void memoryIo_destroy(PHYSFS_Io *io)
         void (*destruct)(void *) = info->destruct;
         void *buf = (void *) info->buf;
         io->opaque = NULL;  /* kill this here in case of race. */
-        destruct = info->destruct;
         allocator.Free(info);
         allocator.Free(io);
         if (destruct != NULL)
-        destruct(buf);
+            destruct(buf);
     } /* if */
 } /* memoryIo_destroy */
 
@@ -2388,11 +2387,10 @@ static PHYSFS_sint64 doBufferedRead(FileHandle *fh, void *buffer,
         buffer = ((PHYSFS_uint8 *) buffer) + buffered;
         len -= buffered;
         retval = buffered;
-        buffered = fh->buffill = fh->bufpos = 0;
+        fh->buffill = fh->bufpos = 0;
     } /* if */
 
     /* if you got here, the buffer is drained and we still need bytes. */
-    assert(buffered == 0);
     assert(len > 0);
 
     io = fh->io;