From 57a5e3b6a523a409b19c68b4316f42082b53cb2c Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Sat, 20 Aug 2016 21:07:31 +0200 Subject: [PATCH] webp_quality should return '0' in case of success. -> clarify the return value in case of error Change-Id: I6f1e675c80d237b302fada28e7612a684b931c7a --- extras/webp_quality.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; }