Fixed up some bugs that clang's static analysis reported.
This commit is contained in:
parent
bbd356a27b
commit
9d11b991bc
|
@ -525,19 +525,22 @@ static int QPAK_stat(dvoid *opaque, const char *filename, int *exists,
|
||||||
const QPAKinfo *info = (const QPAKinfo *) opaque;
|
const QPAKinfo *info = (const QPAKinfo *) opaque;
|
||||||
const QPAKentry *entry = qpak_find_entry(info, filename, &isDir);
|
const QPAKentry *entry = qpak_find_entry(info, filename, &isDir);
|
||||||
|
|
||||||
*exists = ((isDir) || (entry != NULL));
|
|
||||||
if (!exists)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (isDir)
|
if (isDir)
|
||||||
{
|
{
|
||||||
|
*exists = 1;
|
||||||
stat->filetype = PHYSFS_FILETYPE_DIRECTORY;
|
stat->filetype = PHYSFS_FILETYPE_DIRECTORY;
|
||||||
stat->filesize = 0;
|
stat->filesize = 0;
|
||||||
} /* if */
|
} /* if */
|
||||||
else
|
else if (entry != NULL)
|
||||||
{
|
{
|
||||||
|
*exists = 1;
|
||||||
stat->filetype = PHYSFS_FILETYPE_REGULAR;
|
stat->filetype = PHYSFS_FILETYPE_REGULAR;
|
||||||
stat->filesize = entry->size;
|
stat->filesize = entry->size;
|
||||||
|
} /* else if */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*exists = 0;
|
||||||
|
return 0;
|
||||||
} /* else */
|
} /* else */
|
||||||
|
|
||||||
stat->modtime = -1;
|
stat->modtime = -1;
|
||||||
|
|
|
@ -216,7 +216,7 @@ PHYSFS_Io *UNPK_openRead(dvoid *opaque, const char *fnm, int *fileExists)
|
||||||
{
|
{
|
||||||
PHYSFS_Io *retval = NULL;
|
PHYSFS_Io *retval = NULL;
|
||||||
UNPKinfo *info = (UNPKinfo *) opaque;
|
UNPKinfo *info = (UNPKinfo *) opaque;
|
||||||
UNPKfileinfo *finfo;
|
UNPKfileinfo *finfo = NULL;
|
||||||
UNPKentry *entry;
|
UNPKentry *entry;
|
||||||
|
|
||||||
entry = findEntry(info, fnm);
|
entry = findEntry(info, fnm);
|
||||||
|
|
|
@ -394,11 +394,10 @@ static void memoryIo_destroy(PHYSFS_Io *io)
|
||||||
void (*destruct)(void *) = info->destruct;
|
void (*destruct)(void *) = info->destruct;
|
||||||
void *buf = (void *) info->buf;
|
void *buf = (void *) info->buf;
|
||||||
io->opaque = NULL; /* kill this here in case of race. */
|
io->opaque = NULL; /* kill this here in case of race. */
|
||||||
destruct = info->destruct;
|
|
||||||
allocator.Free(info);
|
allocator.Free(info);
|
||||||
allocator.Free(io);
|
allocator.Free(io);
|
||||||
if (destruct != NULL)
|
if (destruct != NULL)
|
||||||
destruct(buf);
|
destruct(buf);
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* memoryIo_destroy */
|
} /* memoryIo_destroy */
|
||||||
|
|
||||||
|
@ -2388,11 +2387,10 @@ static PHYSFS_sint64 doBufferedRead(FileHandle *fh, void *buffer,
|
||||||
buffer = ((PHYSFS_uint8 *) buffer) + buffered;
|
buffer = ((PHYSFS_uint8 *) buffer) + buffered;
|
||||||
len -= buffered;
|
len -= buffered;
|
||||||
retval = buffered;
|
retval = buffered;
|
||||||
buffered = fh->buffill = fh->bufpos = 0;
|
fh->buffill = fh->bufpos = 0;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
/* if you got here, the buffer is drained and we still need bytes. */
|
/* if you got here, the buffer is drained and we still need bytes. */
|
||||||
assert(buffered == 0);
|
|
||||||
assert(len > 0);
|
assert(len > 0);
|
||||||
|
|
||||||
io = fh->io;
|
io = fh->io;
|
||||||
|
|
Loading…
Reference in New Issue