From 9d11b991bcf6b6b94a5ebe503f3a7248c44a6c66 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 18 Oct 2011 15:55:29 -0400 Subject: [PATCH] Fixed up some bugs that clang's static analysis reported. --- src/archiver_qpak.c | 13 ++++++++----- src/archiver_unpacked.c | 2 +- src/physfs.c | 6 ++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/archiver_qpak.c b/src/archiver_qpak.c index ee069c40..ca3f1fda 100644 --- a/src/archiver_qpak.c +++ b/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; diff --git a/src/archiver_unpacked.c b/src/archiver_unpacked.c index 22275671..ec60c44e 100644 --- a/src/archiver_unpacked.c +++ b/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); diff --git a/src/physfs.c b/src/physfs.c index d1c14555..60114a80 100644 --- a/src/physfs.c +++ b/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;