Fixed two warnings (comparison of signed and unsigned values).

Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13967 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-08-17 18:07:50 +00:00
parent cc5b91374f
commit a4f1e9491d
+17 -23
View File
@@ -817,9 +817,8 @@ void close_outfile(__G) /* GRR: change to return PK-style warning level */
fclose(G.outfile); /* close "data" file... */ fclose(G.outfile); /* close "data" file... */
G.outfile = fopen(G.filename, FOPR); /* ...and reopen for reading */ G.outfile = fopen(G.filename, FOPR); /* ...and reopen for reading */
if (!linktarget || fread(linktarget, 1, ucsize, G.outfile) != if (!linktarget
(int)ucsize) || fread(linktarget, 1, ucsize, G.outfile) != (size_t)ucsize) {
{
Info(slide, 0x201, ((char *)slide, Info(slide, 0x201, ((char *)slide,
"warning: symbolic link (%s) failed\n", FnFilter1(G.filename))); "warning: symbolic link (%s) failed\n", FnFilter1(G.filename)));
if (linktarget) if (linktarget)
@@ -1164,7 +1163,7 @@ static int set_file_attrs( const char *name,
return retval; return retval;
} }
static void setBeOSexfield( const char *path, uch *extra_field ) static void setBeOSexfield(const char *path, uch *extra_field)
{ {
uch *ptr = extra_field; uch *ptr = extra_field;
ush id = 0; ush id = 0;
@@ -1174,9 +1173,8 @@ static void setBeOSexfield( const char *path, uch *extra_field )
uch *attrbuff = NULL; uch *attrbuff = NULL;
int retval; int retval;
if( extra_field == NULL ) { if (extra_field == NULL)
return; return;
}
/* Collect the data from the extra field buffer. */ /* Collect the data from the extra field buffer. */
id = makeword( ptr ); ptr += 2; /* we don't use this... */ id = makeword( ptr ); ptr += 2; /* we don't use this... */
@@ -1185,20 +1183,20 @@ static void setBeOSexfield( const char *path, uch *extra_field )
flags = *ptr; ptr++; flags = *ptr; ptr++;
/* Do a little sanity checking. */ /* Do a little sanity checking. */
if( flags & EB_BE_FL_BADBITS ) { if (flags & EB_BE_FL_BADBITS) {
/* corrupted or unsupported */ /* corrupted or unsupported */
Info(slide, 0x201, ((char *)slide, Info(slide, 0x201, ((char *)slide,
"Unsupported flags set for this BeOS extra field, skipping.\n")); "Unsupported flags set for this BeOS extra field, skipping.\n"));
return; return;
} }
if( size <= EB_BEOS_HLEN ) { if (size <= EB_BEOS_HLEN) {
/* corrupted, unsupported, or truncated */ /* corrupted, unsupported, or truncated */
Info(slide, 0x201, ((char *)slide, Info(slide, 0x201, ((char *)slide,
"BeOS extra field is %d bytes, should be at least %d.\n", size, "BeOS extra field is %d bytes, should be at least %d.\n", size,
EB_BEOS_HLEN)); EB_BEOS_HLEN));
return; return;
} }
if( full_size < ( size - EB_BEOS_HLEN ) ) { if (full_size < (uint32)(size - EB_BEOS_HLEN)) {
/* possible old archive? will this screw up on valid archives? */ /* possible old archive? will this screw up on valid archives? */
Info(slide, 0x201, ((char *)slide, Info(slide, 0x201, ((char *)slide,
"Skipping attributes: BeOS extra field is %d bytes, " "Skipping attributes: BeOS extra field is %d bytes, "
@@ -1207,22 +1205,21 @@ static void setBeOSexfield( const char *path, uch *extra_field )
} }
/* Find the BeOS file attribute data. */ /* Find the BeOS file attribute data. */
if( flags & EB_BE_FL_UNCMPR ) { if (flags & EB_BE_FL_UNCMPR) {
/* Uncompressed data */ /* Uncompressed data */
attrbuff = ptr; attrbuff = ptr;
} else { } else {
/* Compressed data */ /* Compressed data */
attrbuff = (uch *)malloc( full_size ); attrbuff = (uch *)malloc(full_size);
if( attrbuff == NULL ) { if (attrbuff == NULL) {
/* No memory to uncompress attributes */ /* No memory to uncompress attributes */
Info(slide, 0x201, ((char *)slide, Info(slide, 0x201, ((char *)slide,
"Can't allocate memory to uncompress file attributes.\n")); "Can't allocate memory to uncompress file attributes.\n"));
return; return;
} }
retval = memextract( __G__ attrbuff, full_size, retval = memextract(__G__ attrbuff, full_size, ptr, size - EB_BEOS_HLEN);
ptr, size - EB_BEOS_HLEN ); if (retval != PK_OK) {
if( retval != PK_OK ) {
/* error uncompressing attributes */ /* error uncompressing attributes */
Info(slide, 0x201, ((char *)slide, Info(slide, 0x201, ((char *)slide,
"Error uncompressing file attributes.\n")); "Error uncompressing file attributes.\n"));
@@ -1232,24 +1229,21 @@ static void setBeOSexfield( const char *path, uch *extra_field )
/* corrupt, we should _not_ attempt to restore the attrs */ /* corrupt, we should _not_ attempt to restore the attrs */
/* for this file... there's no way to detect what attrs */ /* for this file... there's no way to detect what attrs */
/* are good and which are bad. */ /* are good and which are bad. */
free( attrbuff ); free(attrbuff);
return; return;
} }
} }
/* Now attempt to set the file attributes on the extracted file. */ /* Now attempt to set the file attributes on the extracted file. */
retval = set_file_attrs( path, attrbuff, (off_t)full_size ); retval = set_file_attrs(path, attrbuff, (off_t)full_size);
if( retval != EOK ) { if (retval != EOK) {
Info(slide, 0x201, ((char *)slide, Info(slide, 0x201, ((char *)slide,
"Error writing file attributes.\n")); "Error writing file attributes.\n"));
} }
/* Clean up, if necessary */ /* Clean up, if necessary */
if( attrbuff != ptr ) { if (attrbuff != ptr)
free( attrbuff ); free(attrbuff);
}
return;
} }
#ifdef BEOS_USE_PRINTEXFIELD #ifdef BEOS_USE_PRINTEXFIELD