From da0d9c7d4e15fdc2d8addc3c0a3f3f014fc24434 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 6 Dec 2024 13:11:29 -0800 Subject: [PATCH] examples: exit w/failure w/no args cwebp, gif2webp, img2webp, vwebp and webpinfo are modified in this change to align with the other examples. When given no arguments, the examples print their help output and exit with failure. Bug: webp:42340557, webp:381372617 Change-Id: Ifed4eb79e98233f7aa780c42e489636d0cf4a035 --- examples/cwebp.c | 2 +- examples/gif2webp.c | 2 +- examples/img2webp.c | 2 ++ examples/vwebp.c | 2 +- examples/webpinfo.c | 2 +- extras/vwebp_sdl.c | 6 ++++++ 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index d47f0be0..716a1117 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -698,7 +698,7 @@ int main(int argc, const char* argv[]) { if (argc == 1) { HelpShort(); - FREE_WARGV_AND_RETURN(EXIT_SUCCESS); + FREE_WARGV_AND_RETURN(EXIT_FAILURE); } for (c = 1; c < argc; ++c) { diff --git a/examples/gif2webp.c b/examples/gif2webp.c index 532cfcf6..2b297428 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -158,7 +158,7 @@ int main(int argc, const char* argv[]) { if (argc == 1) { Help(); - FREE_WARGV_AND_RETURN(EXIT_SUCCESS); + FREE_WARGV_AND_RETURN(EXIT_FAILURE); } for (c = 1; c < argc; ++c) { diff --git a/examples/img2webp.c b/examples/img2webp.c index ca1d0fd8..9cfccb43 100644 --- a/examples/img2webp.c +++ b/examples/img2webp.c @@ -229,6 +229,8 @@ int main(int argc, const char* argv[]) { } if (!have_input) { fprintf(stderr, "No input file(s) for generating animation!\n"); + ok = 0; + Help(); goto End; } diff --git a/examples/vwebp.c b/examples/vwebp.c index 7dbda4e2..89e8d8c1 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -568,7 +568,7 @@ int main(int argc, char* argv[]) { if (kParams.file_name == NULL) { printf("missing input file!!\n"); Help(); - FREE_WARGV_AND_RETURN(EXIT_SUCCESS); + FREE_WARGV_AND_RETURN(EXIT_FAILURE); } if (!ImgIoUtilReadFile(kParams.file_name, diff --git a/examples/webpinfo.c b/examples/webpinfo.c index 537e3f5a..ba8f1e12 100644 --- a/examples/webpinfo.c +++ b/examples/webpinfo.c @@ -1132,7 +1132,7 @@ int main(int argc, const char* argv[]) { if (argc == 1) { Help(); - FREE_WARGV_AND_RETURN(EXIT_SUCCESS); + FREE_WARGV_AND_RETURN(EXIT_FAILURE); } // Parse command-line input. diff --git a/extras/vwebp_sdl.c b/extras/vwebp_sdl.c index 04de98f0..1906bf39 100644 --- a/extras/vwebp_sdl.c +++ b/extras/vwebp_sdl.c @@ -57,6 +57,12 @@ int main(int argc, char* argv[]) { INIT_WARGV(argc, argv); + if (argc == 1) { + fprintf(stderr, "Usage: %s [-h] image.webp [more_files.webp...]\n", + argv[0]); + goto Error; + } + for (c = 1; c < argc; ++c) { const char* file = NULL; const uint8_t* webp = NULL;