Skip to content

Commit

Permalink
Approved zeph's comments, fixed a few of my screwups.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 3, 2002
1 parent 7fd9821 commit a366cfe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
9 changes: 2 additions & 7 deletions archivers/grp.c
Expand Up @@ -130,8 +130,7 @@ static PHYSFS_sint64 GRP_read(FileHandle *handle, void *buffer,
void *fh = finfo->handle;
PHYSFS_sint64 curPos = __PHYSFS_platformTell(fh);
PHYSFS_uint64 bytesLeft = (finfo->startPos + finfo->size) - curPos;
/*!!! If objSize is '1' it's quite likely that objsLeft will be greater than 32-bits */
PHYSFS_uint32 objsLeft = (PHYSFS_uint32)(bytesLeft / objSize);
PHYSFS_uint64 objsLeft = (bytesLeft / objSize);

if (objsLeft < objCount)
objCount = objsLeft;
Expand All @@ -158,8 +157,7 @@ static PHYSFS_sint64 GRP_tell(FileHandle *handle)
static int GRP_seek(FileHandle *handle, PHYSFS_uint64 offset)
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
/*!!! Why isn't newPos a 64-bit??? */
int newPos = (int)(finfo->startPos + offset);
PHYSFS_uint64 newPos = (finfo->startPos + offset);

BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
BAIL_IF_MACRO(newPos > finfo->startPos + finfo->size, ERR_PAST_EOF, 0);
Expand Down Expand Up @@ -289,7 +287,6 @@ static LinkedStringList *GRP_enumerateFiles(DirHandle *h,
PHYSFS_uint8 buf[16];
GRPinfo *g = (GRPinfo *) (h->opaque);
void *fh = g->handle;
/*!!! This should be a uint32 and not an int...look at loops below */
PHYSFS_uint32 i;
LinkedStringList *retval = NULL;
LinkedStringList *l = NULL;
Expand All @@ -302,7 +299,6 @@ static LinkedStringList *GRP_enumerateFiles(DirHandle *h,
/* jump to first file entry... */
BAIL_IF_MACRO(!__PHYSFS_platformSeek(fh, 16), NULL, NULL);

/*!!! i needs to be unsigned */
for (i = 0; i < g->totalEntries; i++)
{
BAIL_IF_MACRO(__PHYSFS_platformRead(fh, buf, 16, 1) != 1, NULL, retval);
Expand Down Expand Up @@ -341,7 +337,6 @@ static PHYSFS_sint32 getFileEntry(DirHandle *h, const char *name,
PHYSFS_uint8 buf[16];
GRPinfo *g = (GRPinfo *) (h->opaque);
void *fh = g->handle;
/*!!! This should be a uint32 and not an int...look at loops below */
PHYSFS_uint32 i;
char *ptr;
int retval = (g->totalEntries + 1) * 16; /* offset of raw file data */
Expand Down
6 changes: 1 addition & 5 deletions archivers/zip.c
Expand Up @@ -168,8 +168,6 @@ static int ZIP_seek(FileHandle *handle, PHYSFS_uint64 offset)

while (offset > 0)
{
/* !!! - RYAN, CHECK THIS CAST */
/* !!! This should be okay since offset will be <= bufsize */
PHYSFS_uint32 chunk = (offset > bufsize) ? bufsize : (PHYSFS_uint32)offset;
PHYSFS_sint32 rc = unzReadCurrentFile(fh, buf, chunk);
BAIL_IF_MACRO(rc == 0, ERR_IO_ERROR, 0); /* shouldn't happen. */
Expand Down Expand Up @@ -273,9 +271,7 @@ static char *ZIP_realpath(unzFile fh, unz_file_info *info, ZIPentry *entry)
static int version_does_symlinks(uLong version)
{
int retval = 0;
/* !!! - RYAN, CHECK THIS CAST */
/* !!! - You AND the result with 0xFF, so it can't be larger than 0xFF */
unsigned char hosttype = (unsigned char)((version >> 8) & 0xFF);
PHYSFS_uint8 hosttype = (PHYSFS_uint8) ((version >> 8) & 0xFF);

/*
* These are the platforms that can build an archive with symlinks,
Expand Down
10 changes: 4 additions & 6 deletions physfs.c
Expand Up @@ -21,7 +21,7 @@

typedef struct __PHYSFS_ERRMSGTYPE__
{
int tid;
PHYSFS_uint64 tid;
int errorAvailable;
char errorString[80];
struct __PHYSFS_ERRMSGTYPE__ *next;
Expand Down Expand Up @@ -105,13 +105,12 @@ static void *stateLock = NULL; /* protects other PhysFS static state. */
static ErrMsg *findErrorForCurrentThread(void)
{
ErrMsg *i;
int tid;
PHYSFS_uint64 tid;

__PHYSFS_platformGrabMutex(errorLock);
if (errorMessages != NULL)
{
/*!!! I think tid needs to be a 64-bit value??? */
tid = (int)__PHYSFS_platformGetThreadID();
tid = __PHYSFS_platformGetThreadID();

for (i = errorMessages; i != NULL; i = i->next)
{
Expand Down Expand Up @@ -144,8 +143,7 @@ void __PHYSFS_setError(const char *str)
return; /* uhh...? */

memset((void *) err, '\0', sizeof (ErrMsg));
/*!!! I think tid needs to be a 64-bit value??? */
err->tid = (int)__PHYSFS_platformGetThreadID();
err->tid = __PHYSFS_platformGetThreadID();

__PHYSFS_platformGrabMutex(errorLock);
err->next = errorMessages;
Expand Down

0 comments on commit a366cfe

Please sign in to comment.