From 4abe04a204af9f6c384899fb2f570931498f97ea Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Wed, 9 May 2012 00:32:20 -0700 Subject: [PATCH] fix the return value and handle missing input file case. Change-Id: I42a64fcf7587ff3a487115808e2cfa51cec0031d --- examples/cwebp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index 31da0860..7c1fb1a8 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -776,6 +776,7 @@ static const char* const kErrorMessages[] = { //------------------------------------------------------------------------------ int main(int argc, const char *argv[]) { + int return_value = -1; const char *in_file = NULL, *out_file = NULL, *dump_file = NULL; FILE *out = NULL; int c; @@ -943,6 +944,11 @@ int main(int argc, const char *argv[]) { in_file = argv[c]; } } + if (in_file == NULL) { + fprintf(stderr, "No input file specified!\n"); + HelpShort(); + goto Error; + } if (!WebPValidateConfig(&config)) { fprintf(stderr, "Error! Invalid configuration.\n"); @@ -1038,6 +1044,7 @@ int main(int argc, const char *argv[]) { (print_distortion == 1) ? "PSNR" : "SSIM", values[0], values[1], values[2], values[3], values[4]); } + return_value = 0; Error: free(picture.extra_info); @@ -1047,7 +1054,7 @@ int main(int argc, const char *argv[]) { fclose(out); } - return 0; + return return_value; } //------------------------------------------------------------------------------