From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>,
Frodo Looijaard <frodo@frodo.looijaard.name>
Subject: [PATCH 08/11] getopt: remove unnecessary code
Date: Sun, 7 Dec 2014 10:13:52 +0000 [thread overview]
Message-ID: <1417947235-24229-8-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1417947235-24229-1-git-send-email-kerolasa@iki.fi>
The control structure is initialized in main().
CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
misc-utils/getopt.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c
index 696e87a..67603b5 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;
--
2.1.3
next prev parent reply other threads:[~2014-12-07 10:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-07 10:13 [PATCH 01/11] tests: copy test-suite from Frodo Looijaard's getopt Sami Kerola
2014-12-07 10:13 ` [PATCH 02/11] tests: add more getopt tests Sami Kerola
2014-12-07 10:13 ` [PATCH 03/11] getopt: make nonoptions optstring comment correct Sami Kerola
2014-12-07 10:13 ` [PATCH 04/11] getopt: remove function prototypes Sami Kerola
2014-12-07 10:13 ` [PATCH 05/11] getopt: add struct getopt_control and remove global variables Sami Kerola
2014-12-07 10:13 ` [PATCH 06/11] getopt: use xstrdup rather than malloc + strcpy Sami Kerola
2014-12-07 10:13 ` [PATCH 07/11] getopt: make normalize() print strings Sami Kerola
2014-12-07 10:13 ` Sami Kerola [this message]
2014-12-07 10:13 ` [PATCH 09/11] getopt: prefer switch-case rather than long if statement Sami Kerola
2014-12-07 10:13 ` [PATCH 10/11] getopt: change --shell argument parsing function Sami Kerola
2014-12-07 10:13 ` [PATCH 11/11] getopt: avoid re-terminating long_option list at every update Sami Kerola
2014-12-08 11:37 ` Sami Kerola
2014-12-08 20:05 ` Sami Kerola
2014-12-09 11:09 ` [PATCH 01/11] tests: copy test-suite from Frodo Looijaard's getopt Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417947235-24229-8-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=frodo@frodo.looijaard.name \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).