[PATCH 2/3] flash_eraseall: move constants out of for loop
Mike Frysinger
vapier.adi at gmail.com
Tue Jun 22 13:33:20 EDT 2010
On Thu, Jun 17, 2010 at 04:42, Shevchenko Andriy wrote:
> --- a/flash_eraseall.c
> +++ b/flash_eraseall.c
> @@ -194,21 +194,21 @@ 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},
> + {"version", no_argument, 0, 0},
> + {"jffs2", no_argument, 0, 'j'},
> + {"quiet", no_argument, 0, 'q'},
> + {"silent", no_argument, 0, 'q'},
> +
> + {0, 0, 0, 0},
> + };
> +
> exe_name = argv[0];
>
> for (;;) {
> int option_index = 0;
> - static const char *short_options = "jq";
> - static const struct option long_options[] = {
> - {"help", no_argument, 0, 0},
> - {"version", no_argument, 0, 0},
> - {"jffs2", no_argument, 0, 'j'},
> - {"quiet", no_argument, 0, 'q'},
> - {"silent", no_argument, 0, 'q'},
> -
> - {0, 0, 0, 0},
> - };
> -
> int c = getopt_long(argc, argv, short_options,
> long_options, &option_index);
> if (c == EOF) {
NAK: no explanation why you're doing this, and current code has the
variables scoped to where they actually get used.
i wonder though why this code even bothers with "static".
-mike
More information about the linux-mtd
mailing list