Patchwork [3/3] flash_eraseall: make -? option the same as --help

login
register
mail settings
Submitter Shevchenko Andriy (EXT-Teleca/Helsinki)
Date June 17, 2010, 8:42 a.m.
Message ID <1276764159-28726-3-git-send-email-ext-andriy.shevchenko@nokia.com>
Download mbox | patch
Permalink /patch/56407/
State New
Headers show

Comments

Shevchenko Andriy (EXT-Teleca/Helsinki) - June 17, 2010, 8:42 a.m.
Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
---
 flash_eraseall.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
Mike Frysinger - June 22, 2010, 5:31 p.m.
On Thu, Jun 17, 2010 at 04:42, Shevchenko Andriy wrote:
> --- a/flash_eraseall.c
> +++ b/flash_eraseall.c
> @@ -192,8 +192,6 @@ int main (int argc, char *argv[])
>
>  void process_options (int argc, char *argv[])
>  {
> -       int error = 0;
> -
>        static const char *short_options = "jq";
>        static const struct option long_options[] = {
>                {"help", no_argument, 0, 0},
> @@ -233,15 +231,13 @@ void process_options (int argc, char *argv[])
>                                jffs2 = 1;
>                                break;
>                        case '?':
> -                               error = 1;
> +                               display_help();
>                                break;
>                }
>        }

NAK.  this isnt "-?", that's the error case of getopt.  look at the
invocation of getopt here ... ? is not a valid char.

also, your patch bombing seems screwed up as linux-mtd was bcc-ed.
-mike

Patch

diff --git a/flash_eraseall.c b/flash_eraseall.c
index f6319d1..ebd329b 100644
--- a/flash_eraseall.c
+++ b/flash_eraseall.c
@@ -192,8 +192,6 @@  int main (int argc, char *argv[])
 
 void process_options (int argc, char *argv[])
 {
-	int error = 0;
-
 	static const char *short_options = "jq";
 	static const struct option long_options[] = {
 		{"help", no_argument, 0, 0},
@@ -233,15 +231,13 @@  void process_options (int argc, char *argv[])
 				jffs2 = 1;
 				break;
 			case '?':
-				error = 1;
+				display_help();
 				break;
 		}
 	}
+
 	if (optind == argc) {
 		fprintf(stderr, "%s: no MTD device specified\n", exe_name);
-		error = 1;
-	}
-	if (error) {
 		fprintf(stderr, "Try `%s --help' for more information.\n",
 				exe_name);
 		exit(1);