examples: don't use C99 %zu

this would require a PRIuS or similar macro for proper platform
compatibility (Visual Studio for instance would be variants of %lu)

Change-Id: I1af530c7c358c91b845acde1d8c12ef46c2ef746
This commit is contained in:
James Zern 2013-03-20 16:59:35 -07:00
parent 5ccf1fe540
commit 14d42af207
5 changed files with 16 additions and 15 deletions

View File

@ -380,13 +380,13 @@ static void PrintMetadataInfo(const Metadata* const metadata,
fprintf(stderr, "Metadata:\n"); fprintf(stderr, "Metadata:\n");
if (metadata_written & METADATA_ICC) { if (metadata_written & METADATA_ICC) {
fprintf(stderr, " * ICC profile: %6zu bytes\n", metadata->iccp.size); fprintf(stderr, " * ICC profile: %6d bytes\n", (int)metadata->iccp.size);
} }
if (metadata_written & METADATA_EXIF) { if (metadata_written & METADATA_EXIF) {
fprintf(stderr, " * EXIF data: %6zu bytes\n", metadata->exif.size); fprintf(stderr, " * EXIF data: %6d bytes\n", (int)metadata->exif.size);
} }
if (metadata_written & METADATA_XMP) { if (metadata_written & METADATA_XMP) {
fprintf(stderr, " * XMP data: %6zu bytes\n", metadata->xmp.size); fprintf(stderr, " * XMP data: %6d bytes\n", (int)metadata->xmp.size);
} }
} }

View File

@ -44,8 +44,8 @@ int ExUtilReadFile(const char* const file_name,
fclose(in); fclose(in);
if (!ok) { if (!ok) {
fprintf(stderr, "Could not read %zu bytes of data from file %s\n", fprintf(stderr, "Could not read %d bytes of data from file %s\n",
file_size, file_name); (int)file_size, file_name);
free(file_data); free(file_data);
return 0; return 0;
} }

View File

@ -401,7 +401,7 @@ int main(int argc, const char *argv[]) {
xmp.bytes = (uint8_t*)data; xmp.bytes = (uint8_t*)data;
xmp.size = data[0] + 1; xmp.size = data[0] + 1;
WebPMuxSetChunk(mux, "XMP ", &xmp, 1); WebPMuxSetChunk(mux, "XMP ", &xmp, 1);
if (verbose) printf("XMP size: %zu\n", xmp.size); if (verbose) printf("XMP size: %d\n", (int)xmp.size);
} else if (!memcmp(data + 1, "ICCRGBG1012", 11)) { } else if (!memcmp(data + 1, "ICCRGBG1012", 11)) {
// Read ICC profile. // Read ICC profile.
WebPData icc; WebPData icc;
@ -410,7 +410,7 @@ int main(int argc, const char *argv[]) {
icc.bytes = (uint8_t*)data; icc.bytes = (uint8_t*)data;
icc.size = data[0] + 1; icc.size = data[0] + 1;
WebPMuxSetChunk(mux, "ICCP", &icc, 1); WebPMuxSetChunk(mux, "ICCP", &icc, 1);
if (verbose) printf("ICC size: %zu\n", icc.size); if (verbose) printf("ICC size: %d\n", (int)icc.size);
} }
break; break;
} }

View File

@ -79,9 +79,9 @@ static int StoreICCP(j_decompress_ptr dinfo, MetadataPayload* const iccp) {
ICCPSegment* segment; ICCPSegment* segment;
if (segment_size == 0 || count == 0 || seq == 0) { if (segment_size == 0 || count == 0 || seq == 0) {
fprintf(stderr, "[ICCP] size (%zu) / count (%d) / sequence number (%d)" fprintf(stderr, "[ICCP] size (%d) / count (%d) / sequence number (%d)"
" cannot be 0!\n", " cannot be 0!\n",
segment_size, seq, count); (int)segment_size, seq, count);
return 0; return 0;
} }

View File

@ -232,7 +232,7 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i); RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i);
printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset); printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset);
if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method); if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method);
printf("%10zu\n", frame.bitstream.size); printf("%10d\n", (int)frame.bitstream.size);
WebPDataClear(&frame.bitstream); WebPDataClear(&frame.bitstream);
} }
} }
@ -242,28 +242,28 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
WebPData icc_profile; WebPData icc_profile;
err = WebPMuxGetChunk(mux, "ICCP", &icc_profile); err = WebPMuxGetChunk(mux, "ICCP", &icc_profile);
RETURN_IF_ERROR("Failed to retrieve the ICC profile\n"); RETURN_IF_ERROR("Failed to retrieve the ICC profile\n");
printf("Size of the ICC profile data: %zu\n", icc_profile.size); printf("Size of the ICC profile data: %d\n", (int)icc_profile.size);
} }
if (flag & EXIF_FLAG) { if (flag & EXIF_FLAG) {
WebPData exif; WebPData exif;
err = WebPMuxGetChunk(mux, "EXIF", &exif); err = WebPMuxGetChunk(mux, "EXIF", &exif);
RETURN_IF_ERROR("Failed to retrieve the EXIF metadata\n"); RETURN_IF_ERROR("Failed to retrieve the EXIF metadata\n");
printf("Size of the EXIF metadata: %zu\n", exif.size); printf("Size of the EXIF metadata: %d\n", (int)exif.size);
} }
if (flag & XMP_FLAG) { if (flag & XMP_FLAG) {
WebPData xmp; WebPData xmp;
err = WebPMuxGetChunk(mux, "XMP ", &xmp); err = WebPMuxGetChunk(mux, "XMP ", &xmp);
RETURN_IF_ERROR("Failed to retrieve the XMP metadata\n"); RETURN_IF_ERROR("Failed to retrieve the XMP metadata\n");
printf("Size of the XMP metadata: %zu\n", xmp.size); printf("Size of the XMP metadata: %d\n", (int)xmp.size);
} }
if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | FRAGMENTS_FLAG))) { if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | FRAGMENTS_FLAG))) {
WebPMuxFrameInfo image; WebPMuxFrameInfo image;
err = WebPMuxGetFrame(mux, 1, &image); err = WebPMuxGetFrame(mux, 1, &image);
RETURN_IF_ERROR("Failed to retrieve the image\n"); RETURN_IF_ERROR("Failed to retrieve the image\n");
printf("Size of the image (with alpha): %zu\n", image.bitstream.size); printf("Size of the image (with alpha): %d\n", (int)image.bitstream.size);
} }
return WEBP_MUX_OK; return WEBP_MUX_OK;
@ -382,7 +382,8 @@ static int WriteData(const char* filename, const WebPData* const webpdata) {
if (fwrite(webpdata->bytes, webpdata->size, 1, fout) != 1) { if (fwrite(webpdata->bytes, webpdata->size, 1, fout) != 1) {
fprintf(stderr, "Error writing file %s!\n", filename); fprintf(stderr, "Error writing file %s!\n", filename);
} else { } else {
fprintf(stderr, "Saved file %s (%zu bytes)\n", filename, webpdata->size); fprintf(stderr, "Saved file %s (%d bytes)\n",
filename, (int)webpdata->size);
ok = 1; ok = 1;
} }
if (fout != stdout) fclose(fout); if (fout != stdout) fclose(fout);