Browse Source

[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>
tags/v0.9.9
Joshua Oreman 15 years ago
parent
commit
0677a383e0
1 changed files with 8 additions and 8 deletions
  1. 8
    8
      src/util/zbin.c

+ 8
- 8
src/util/zbin.c View File

81
 	*len = stat.st_size;
81
 	*len = stat.st_size;
82
 	*buf = malloc ( *len );
82
 	*buf = malloc ( *len );
83
 	if ( ! *buf ) {
83
 	if ( ! *buf ) {
84
-		fprintf ( stderr, "Could not malloc() %d bytes for %s: %s\n",
84
+		fprintf ( stderr, "Could not malloc() %zd bytes for %s: %s\n",
85
 			  *len, filename, strerror ( errno ) );
85
 			  *len, filename, strerror ( errno ) );
86
 		goto err;
86
 		goto err;
87
 	}
87
 	}
88
 
88
 
89
 	if ( fread ( *buf, 1, *len, file ) != *len ) {
89
 	if ( fread ( *buf, 1, *len, file ) != *len ) {
90
-		fprintf ( stderr, "Could not read %d bytes from %s: %s\n",
90
+		fprintf ( stderr, "Could not read %zd bytes from %s: %s\n",
91
 			  *len, filename, strerror ( errno ) );
91
 			  *len, filename, strerror ( errno ) );
92
 		goto err;
92
 		goto err;
93
 	}
93
 	}
115
 		return -1;
115
 		return -1;
116
 
116
 
117
 	if ( ( len % sizeof ( *(zinfo->zinfo) ) ) != 0 ) {
117
 	if ( ( len % sizeof ( *(zinfo->zinfo) ) ) != 0 ) {
118
-		fprintf ( stderr, ".zinfo file %s has invalid length %d\n",
118
+		fprintf ( stderr, ".zinfo file %s has invalid length %zd\n",
119
 			  filename, len );
119
 			  filename, len );
120
 		return -1;
120
 		return -1;
121
 	}
121
 	}
130
 	output->max_len = ( max_len );
130
 	output->max_len = ( max_len );
131
 	output->buf = malloc ( max_len );
131
 	output->buf = malloc ( max_len );
132
 	if ( ! output->buf ) {
132
 	if ( ! output->buf ) {
133
-		fprintf ( stderr, "Could not allocate %d bytes for output\n",
133
+		fprintf ( stderr, "Could not allocate %zd bytes for output\n",
134
 			  max_len );
134
 			  max_len );
135
 		return -1;
135
 		return -1;
136
 	}
136
 	}
240
 		addend = *( ( int32_t * ) target );
240
 		addend = *( ( int32_t * ) target );
241
 		break;
241
 		break;
242
 	default:
242
 	default:
243
-		fprintf ( stderr, "Unsupported add datasize %d\n",
243
+		fprintf ( stderr, "Unsupported add datasize %zd\n",
244
 			  datasize );
244
 			  datasize );
245
 		return -1;
245
 		return -1;
246
 	}
246
 	}
259
 	}
259
 	}
260
 
260
 
261
 	if ( val & ~mask ) {
261
 	if ( val & ~mask ) {
262
-		fprintf ( stderr, "Add %s%#x+%#lx at %#zx overflows %d-byte "
262
+		fprintf ( stderr, "Add %s%#x+%#lx at %#zx overflows %zd-byte "
263
 			  "field (%d bytes too big)\n",
263
 			  "field (%d bytes too big)\n",
264
 			  ( ( addend < 0 ) ? "-" : "" ), abs ( addend ), size,
264
 			  ( ( addend < 0 ) ? "-" : "" ), abs ( addend ), size,
265
 			  offset, datasize,
265
 			  offset, datasize,
280
 	}
280
 	}
281
 
281
 
282
 	if ( DEBUG ) {
282
 	if ( DEBUG ) {
283
-		fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#x+(%#x/%#x)) = "
283
+		fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#x+(%#zx/%#x)) = "
284
 			  "%#lx\n", offset, ( offset + datasize ),
284
 			  "%#lx\n", offset, ( offset + datasize ),
285
 			  ( ( addend < 0 ) ? "-" : "" ), abs ( addend ),
285
 			  ( ( addend < 0 ) ? "-" : "" ), abs ( addend ),
286
 			  output->len, add->divisor, val );
286
 			  output->len, add->divisor, val );
344
 
344
 
345
 static int write_output_file ( struct output_file *output ) {
345
 static int write_output_file ( struct output_file *output ) {
346
 	if ( fwrite ( output->buf, 1, output->len, stdout ) != output->len ) {
346
 	if ( fwrite ( output->buf, 1, output->len, stdout ) != output->len ) {
347
-		fprintf ( stderr, "Could not write %d bytes of output: %s\n",
347
+		fprintf ( stderr, "Could not write %zd bytes of output: %s\n",
348
 			  output->len, strerror ( errno ) );
348
 			  output->len, strerror ( errno ) );
349
 		return -1;
349
 		return -1;
350
 	}
350
 	}

Loading…
Cancel
Save