Pārlūkot izejas kodu

[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 gadus atpakaļ
vecāks
revīzija
0677a383e0
1 mainītis faili ar 8 papildinājumiem un 8 dzēšanām
  1. 8
    8
      src/util/zbin.c

+ 8
- 8
src/util/zbin.c Parādīt failu

@@ -81,13 +81,13 @@ static int read_file ( const char *filename, void **buf, size_t *len ) {
81 81
 	*len = stat.st_size;
82 82
 	*buf = malloc ( *len );
83 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 85
 			  *len, filename, strerror ( errno ) );
86 86
 		goto err;
87 87
 	}
88 88
 
89 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 91
 			  *len, filename, strerror ( errno ) );
92 92
 		goto err;
93 93
 	}
@@ -115,7 +115,7 @@ static int read_zinfo_file ( const char *filename,
115 115
 		return -1;
116 116
 
117 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 119
 			  filename, len );
120 120
 		return -1;
121 121
 	}
@@ -130,7 +130,7 @@ static int alloc_output_file ( size_t max_len, struct output_file *output ) {
130 130
 	output->max_len = ( max_len );
131 131
 	output->buf = malloc ( max_len );
132 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 134
 			  max_len );
135 135
 		return -1;
136 136
 	}
@@ -240,7 +240,7 @@ static int process_zinfo_add ( struct input_file *input,
240 240
 		addend = *( ( int32_t * ) target );
241 241
 		break;
242 242
 	default:
243
-		fprintf ( stderr, "Unsupported add datasize %d\n",
243
+		fprintf ( stderr, "Unsupported add datasize %zd\n",
244 244
 			  datasize );
245 245
 		return -1;
246 246
 	}
@@ -259,7 +259,7 @@ static int process_zinfo_add ( struct input_file *input,
259 259
 	}
260 260
 
261 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 263
 			  "field (%d bytes too big)\n",
264 264
 			  ( ( addend < 0 ) ? "-" : "" ), abs ( addend ), size,
265 265
 			  offset, datasize,
@@ -280,7 +280,7 @@ static int process_zinfo_add ( struct input_file *input,
280 280
 	}
281 281
 
282 282
 	if ( DEBUG ) {
283
-		fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#x+(%#x/%#x)) = "
283
+		fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#x+(%#zx/%#x)) = "
284 284
 			  "%#lx\n", offset, ( offset + datasize ),
285 285
 			  ( ( addend < 0 ) ? "-" : "" ), abs ( addend ),
286 286
 			  output->len, add->divisor, val );
@@ -344,7 +344,7 @@ static int process_zinfo ( struct input_file *input,
344 344
 
345 345
 static int write_output_file ( struct output_file *output ) {
346 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 348
 			  output->len, strerror ( errno ) );
349 349
 		return -1;
350 350
 	}

Notiek ielāde…
Atcelt
Saglabāt