Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed up some bugs that clang's static analysis reported.
  • Loading branch information
icculus committed Oct 18, 2011
1 parent bbd356a commit 9d11b99
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
13 changes: 8 additions & 5 deletions src/archiver_qpak.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/archiver_unpacked.c
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions src/physfs.c
Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9d11b99

Please sign in to comment.