Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[zbin] Fix 64-bit compilation warnings for util/zbin.c
Recent gcc versions generate more warnings when compiling util/zbin.c
on a 64-bit system:

util/zbin.c: In function `read_file':
util/zbin.c:85: warning: format `%d' expects type `int', but
                argument 3 has type `size_t'
util/zbin.c:91: warning: format `%d' expects type `int', but
                argument 3 has type `size_t'
util/zbin.c: In function `read_zinfo_file':
util/zbin.c:119: warning: format `%d' expects type `int', but
                 argument 4 has type `size_t'
util/zbin.c: In function `alloc_output_file':
util/zbin.c:134: warning: format `%d' expects type `int', but
                 argument 3 has type `size_t'
util/zbin.c: In function `process_zinfo_add':
util/zbin.c:244: warning: format `%d' expects type `int', but
                 argument 3 has type `size_t'
util/zbin.c:266: warning: format `%d' expects type `int', but
                 argument 7 has type `size_t'
util/zbin.c:286: warning: format `%#x' expects type `unsigned int',
                 but argument 7 has type `size_t'
util/zbin.c: In function `write_output_file':
util/zbin.c:348: warning: format `%d' expects type `int', but
                 argument 3 has type `size_t'

This patch eliminates these warnings.

Signed-off-by: Marty Connor <mdc@etherboot.org>
  • Loading branch information
rwcr authored and Marty Connor committed Oct 20, 2009
1 parent 15b46c5 commit 0677a38
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/util/zbin.c
Expand Up @@ -81,13 +81,13 @@ static int read_file ( const char *filename, void **buf, size_t *len ) {
*len = stat.st_size;
*buf = malloc ( *len );
if ( ! *buf ) {
fprintf ( stderr, "Could not malloc() %d bytes for %s: %s\n",
fprintf ( stderr, "Could not malloc() %zd bytes for %s: %s\n",
*len, filename, strerror ( errno ) );
goto err;
}

if ( fread ( *buf, 1, *len, file ) != *len ) {
fprintf ( stderr, "Could not read %d bytes from %s: %s\n",
fprintf ( stderr, "Could not read %zd bytes from %s: %s\n",
*len, filename, strerror ( errno ) );
goto err;
}
Expand Down Expand Up @@ -115,7 +115,7 @@ static int read_zinfo_file ( const char *filename,
return -1;

if ( ( len % sizeof ( *(zinfo->zinfo) ) ) != 0 ) {
fprintf ( stderr, ".zinfo file %s has invalid length %d\n",
fprintf ( stderr, ".zinfo file %s has invalid length %zd\n",
filename, len );
return -1;
}
Expand All @@ -130,7 +130,7 @@ static int alloc_output_file ( size_t max_len, struct output_file *output ) {
output->max_len = ( max_len );
output->buf = malloc ( max_len );
if ( ! output->buf ) {
fprintf ( stderr, "Could not allocate %d bytes for output\n",
fprintf ( stderr, "Could not allocate %zd bytes for output\n",
max_len );
return -1;
}
Expand Down Expand Up @@ -240,7 +240,7 @@ static int process_zinfo_add ( struct input_file *input,
addend = *( ( int32_t * ) target );
break;
default:
fprintf ( stderr, "Unsupported add datasize %d\n",
fprintf ( stderr, "Unsupported add datasize %zd\n",
datasize );
return -1;
}
Expand All @@ -259,7 +259,7 @@ static int process_zinfo_add ( struct input_file *input,
}

if ( val & ~mask ) {
fprintf ( stderr, "Add %s%#x+%#lx at %#zx overflows %d-byte "
fprintf ( stderr, "Add %s%#x+%#lx at %#zx overflows %zd-byte "
"field (%d bytes too big)\n",
( ( addend < 0 ) ? "-" : "" ), abs ( addend ), size,
offset, datasize,
Expand All @@ -280,7 +280,7 @@ static int process_zinfo_add ( struct input_file *input,
}

if ( DEBUG ) {
fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#x+(%#x/%#x)) = "
fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#x+(%#zx/%#x)) = "
"%#lx\n", offset, ( offset + datasize ),
( ( addend < 0 ) ? "-" : "" ), abs ( addend ),
output->len, add->divisor, val );
Expand Down Expand Up @@ -344,7 +344,7 @@ static int process_zinfo ( struct input_file *input,

static int write_output_file ( struct output_file *output ) {
if ( fwrite ( output->buf, 1, output->len, stdout ) != output->len ) {
fprintf ( stderr, "Could not write %d bytes of output: %s\n",
fprintf ( stderr, "Could not write %zd bytes of output: %s\n",
output->len, strerror ( errno ) );
return -1;
}
Expand Down

0 comments on commit 0677a38

Please sign in to comment.