From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52239 invoked by alias); 5 Dec 2019 15:28:55 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 52230 invoked by uid 89); 5 Dec 2019 15:28:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mx1.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Date: Tue, 01 Jan 2019 00:00:00 -0000 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Subject: [committed] Add file variable in main Message-ID: <20191205152849.GA26238@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2019-q4/txt/msg00117.txt.bz2 Hi, Factor out variable file in main, and use it in the dwz calls. Committed to trunk. Thanks, - Tom Add file variable in main 2019-12-03 Tom de Vries * dwz.c (main): Factor out file variable. --- dwz.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/dwz.c b/dwz.c index 54e1918..1c1ae93 100644 --- a/dwz.c +++ b/dwz.c @@ -13287,6 +13287,7 @@ main (int argc, char *argv[]) char *end; struct file_result res; bool hardlink = false; + const char *file; if (elf_version (EV_CURRENT) == EV_NONE) error (1, 0, "library out of date\n"); @@ -13390,6 +13391,7 @@ main (int argc, char *argv[]) if (optind == argc || optind + 1 == argc) { + file = optind == argc ? "a.out" : argv[optind]; if (multifile != NULL) { error (0, 0, "Too few files for multifile optimization"); @@ -13398,13 +13400,11 @@ main (int argc, char *argv[]) res.die_count = 0; ret = (low_mem_die_limit == 0 ? 2 - : dwz (optind == argc ? "a.out" : argv[optind], outfile, - &res, NULL, NULL)); + : dwz (file, outfile, &res, NULL, NULL)); if (ret == 2) { multifile_mode = MULTIFILE_MODE_LOW_MEM; - ret = dwz (optind == argc ? "a.out" : argv[optind], outfile, - &res, NULL, NULL); + ret = dwz (file, outfile, &res, NULL, NULL); } } else @@ -13440,14 +13440,16 @@ main (int argc, char *argv[]) } for (i = optind; i < argc; i++) { - int thisret = (low_mem_die_limit == 0 - ? 2 - : dwz (argv[i], NULL, &resa[i - optind], - hardlinks ? resa : NULL, &argv[optind])); + int thisret; + file = argv[i]; + thisret = (low_mem_die_limit == 0 + ? 2 + : dwz (file, NULL, &resa[i - optind], + hardlinks ? resa : NULL, &argv[optind])); if (thisret == 2) { multifile_mode = MULTIFILE_MODE_LOW_MEM; - thisret = dwz (argv[i], NULL, &resa[i - optind], + thisret = dwz (file, NULL, &resa[i - optind], hardlinks ? resa : NULL, &argv[optind]); } else if (resa[i - optind].res == 0) @@ -13486,6 +13488,7 @@ main (int argc, char *argv[]) for (i = optind; i < argc; i++) { dw_cu_ref cu; + file = argv[i]; multifile_mode = MULTIFILE_MODE_FI; /* Don't process again files that couldn't be processed successfully. */ @@ -13494,7 +13497,7 @@ main (int argc, char *argv[]) continue; for (cu = alt_first_cu; cu; cu = cu->cu_next) alt_clear_dups (cu->cu_die); - ret |= dwz (argv[i], NULL, &resa[i - optind], + ret |= dwz (file, NULL, &resa[i - optind], hardlinks ? resa : NULL, &argv[optind]); } elf_end (dso->elf);