From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org
Subject: [committed] Make main more readable
Date: Wed, 17 Mar 2021 14:14:45 +0100 [thread overview]
Message-ID: <20210317131444.GA11885@delia> (raw)
Hi,
Use variables nr_files and files in main instead of optind, where possible.
Committed to trunk.
Thanks,
- Tom
Make main more readable
2021-03-17 Tom de Vries <tdevries@suse.de>
* dwz.c (main): Use nr_files and files instead of optind.
---
dwz.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/dwz.c b/dwz.c
index 8f64a34..c5a27be 100644
--- a/dwz.c
+++ b/dwz.c
@@ -17041,6 +17041,8 @@ main (int argc, char *argv[])
int ret;
const char *outfile;
bool hardlink;
+ int nr_files;
+ const char **files;
if (elf_version (EV_CURRENT) == EV_NONE)
error (1, 0, "library out of date");
@@ -17048,10 +17050,12 @@ main (int argc, char *argv[])
outfile = NULL;
hardlink = false;
parse_args (argc, argv, &hardlink, &outfile);
+ nr_files = argc - optind;
+ files = (const char **)&argv[optind];
- if (optind == argc || optind + 1 == argc)
+ if (nr_files <= 1)
{
- const char *file = optind == argc ? "a.out" : argv[optind];
+ const char *file = nr_files == 0 ? "a.out" : files[0];
if (multifile != NULL)
{
@@ -17063,9 +17067,6 @@ main (int argc, char *argv[])
}
else
{
- int nr_files = argc - optind;
- const char **files = (const char **)&argv[optind];
-
if (outfile != NULL)
error (1, 0, "-o option not allowed for multiple files");
next reply other threads:[~2021-03-17 13:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 13:14 Tom de Vries [this message]
2021-03-17 13:18 ` Jakub Jelinek
2021-03-17 13:37 ` Tom de Vries
2021-03-17 17:28 ` Jakub Jelinek
2021-03-18 10:30 ` Tom de Vries
2021-03-18 18:52 ` Florian Weimer
2021-03-19 16:43 ` [committed] Change files var in main to char ** Tom de Vries
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=20210317131444.GA11885@delia \
--to=tdevries@suse.de \
--cc=dwz@sourceware.org \
--cc=jakub@redhat.com \
--cc=mark@klomp.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 read-only IMAP folder(s) and NNTP newsgroup(s).