From: Sami Kerola Date: Sat, 6 Dec 2014 18:21:56 +0000 (+0000) Subject: getopt: remove unnecessary code X-Git-Tag: v2.26-rc1~140^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0640689c209357611bd434091552839634f6af76;p=thirdparty%2Futil-linux.git getopt: remove unnecessary code The control structure is initialized in main(). CC: Frodo Looijaard Signed-off-by: Sami Kerola --- diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c index 696e87a19f..67603b52e3 100644 --- a/misc-utils/getopt.c +++ b/misc-utils/getopt.c @@ -232,14 +232,6 @@ static void add_longopt(struct getopt_control *ctl, const char *name, int has_ar { static int flag; - if (!name) { - /* init */ - free(ctl->long_options); - ctl->long_options = NULL; - ctl->long_options_length = 0; - ctl->long_options_nr = 0; - } - if (ctl->long_options_nr == ctl->long_options_length) { ctl->long_options_length += REALLOC_INCREMENT; ctl->long_options = xrealloc(ctl->long_options, @@ -252,7 +244,7 @@ static void add_longopt(struct getopt_control *ctl, const char *name, int has_ar ctl->long_options[ctl->long_options_nr].flag = NULL; ctl->long_options[ctl->long_options_nr].val = 0; - if (ctl->long_options_nr && name) { + if (name) { /* Not for init! */ ctl->long_options[ctl->long_options_nr - 1].has_arg = has_arg; ctl->long_options[ctl->long_options_nr - 1].flag = &flag;