diff --git a/extras/webp_quality.c b/extras/webp_quality.c index 69fc8223..9ab38f03 100644 --- a/extras/webp_quality.c +++ b/extras/webp_quality.c @@ -18,23 +18,25 @@ int main(int argc, const char *argv[]) { int c; int quiet = 0; - for (c = 1; c < argc; ++c) { + int ok = 1; + for (c = 1; ok && c < argc; ++c) { if (!strcmp(argv[c], "-quiet")) { quiet = 1; } else if (!strcmp(argv[c], "-help") || !strcmp(argv[c], "-h")) { printf("webp_quality [-h][-quiet] webp_files...\n"); - return 1; + return 0; } else { const char* const filename = argv[c]; const uint8_t* data = NULL; size_t data_size = 0; int q; - const int ok = ImgIoUtilReadFile(filename, &data, &data_size); - if (!ok) continue; + ok = ImgIoUtilReadFile(filename, &data, &data_size); + if (!ok) break; q = VP8EstimateQuality(data, data_size); if (!quiet) printf("[%s] ", filename); if (q < 0) { fprintf(stderr, "Not a WebP file, or not a lossy WebP file.\n"); + ok = 0; } else { if (!quiet) { printf("Estimated quality factor: %d\n", q); @@ -45,5 +47,5 @@ int main(int argc, const char *argv[]) { free((void*)data); } } - return 1; + return ok ? 0 : 1; }