From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 0A5483858004 for ; Mon, 29 Mar 2021 06:36:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0A5483858004 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 26098B13D; Mon, 29 Mar 2021 06:36:57 +0000 (UTC) Date: Mon, 29 Mar 2021 08:36:55 +0200 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org Subject: [committed] Add ret to struct file_result Message-ID: <20210329063654.GA3469@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-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Mar 2021 06:36:59 -0000 Hi, Further simplify the serial/parallel code in dwz_files_1 by factoring out the return status handling. Add a ret field to struct file_result to store the per-file return status. Committed to trunk. Thanks, - Tom Add ret to struct file_result 2021-03-29 Tom de Vries * dwz.c (struct file_result): Add ret field. (wait_child_exit): Return void. Set ret. (wait_children_exit): Return void. Update call to wait_child_exit. (dwz_files_1): Move return status handling out of serial/parallel code. --- dwz.c | 68 ++++++++++++++++++++++++++++++++----------------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/dwz.c b/dwz.c index 377e1be..de600c1 100644 --- a/dwz.c +++ b/dwz.c @@ -15049,6 +15049,7 @@ struct file_result 0: Processed, changed. 1: Processed, unchanged. */ int res; + int ret; size_t hardlink_to; unsigned int die_count; bool skip_multifile; @@ -16444,7 +16445,7 @@ decode_child_exit_status (int state, struct file_result *res) } /* Wait on child exit with PID, update PIDS and RES. */ -static int +static void wait_child_exit (pid_t pid, pid_t *pids, int nr_pids, struct file_result *resa) { @@ -16460,28 +16461,21 @@ wait_child_exit (pid_t pid, pid_t *pids, int nr_pids, } assert (i < nr_pids); - return decode_child_exit_status (state, &resa[i]); + resa[i].ret = decode_child_exit_status (state, &resa[i]); } /* Wait on exit of chilren in PIDS, update RESA. */ -static int +static void wait_children_exit (pid_t *pids, int nr_files, struct file_result *resa) { - int ret = 0; - int i; for (i = 0; i < nr_files; i++) { - int thisret; struct file_result *res = &resa[i]; if (pids[i] == 0) continue; - thisret = wait_child_exit (pids[i], &pids[i], 1, res); - if (thisret == 1) - ret = 1; + wait_child_exit (pids[i], &pids[i], 1, res); } - - return ret; } /* Dwarf-compress FILES. If HARDLINK, detect if some files are hardlinks and @@ -16540,13 +16534,10 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink, for (j = 0; j < workset_size; j++) { int i = workset[j]; - int thisret; if (nr_forks == max_forks) { - int thisret = wait_child_exit (-1, pids, i, resa); - if (thisret == 1) - ret = 1; + wait_child_exit (-1, pids, i, resa); nr_forks--; } @@ -16556,7 +16547,7 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink, { file = files[i]; struct file_result *res = &resa[i]; - thisret = dwz_with_low_mem (file, NULL, res); + int thisret = dwz_with_low_mem (file, NULL, res); return encode_child_exit_status (thisret, res); } else @@ -16566,30 +16557,32 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink, } } if (nr_forks > 0) - { - int thisret = wait_children_exit (pids, nr_files, resa); - if (thisret == 1) - ret = 1; - } + wait_children_exit (pids, nr_files, resa); } else { for (j = 0; j < workset_size; j++) { int i = workset[j]; - int thisret; file = files[i]; struct file_result *res = &resa[i]; if (stats_p) init_stats (file); - thisret = dwz_with_low_mem (file, NULL, res); - if (thisret == 1) - ret = 1; - else if (!res->low_mem_p && !res->skip_multifile && res->res >= 0) - successcount++; + res->ret = dwz_with_low_mem (file, NULL, res); } } + for (j = 0; j < workset_size; j++) + { + int i = workset[j]; + struct file_result *res = &resa[i]; + int thisret = res->ret; + if (thisret == 1) + ret = 1; + else if (!res->low_mem_p && !res->skip_multifile && res->res >= 0) + successcount++; + } + if (hardlink) update_hardlinks (nr_files, files, resa); @@ -16647,9 +16640,7 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink, if (nr_forks == max_forks) { - int thisret = wait_child_exit (-1, pids, i, resa); - if (thisret == 1) - ret = 1; + wait_child_exit (-1, pids, i, resa); nr_forks--; } @@ -16670,17 +16661,14 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink, } } if (nr_forks > 0) - { - int thisret = wait_children_exit (pids, nr_files, resa); - if (thisret == 1) - ret = 1; - } + wait_children_exit (pids, nr_files, resa); } else { for (j = 0; j < workset_size; j++) { int i = workset[j]; + struct file_result *res = &resa[i]; dw_cu_ref cu; file = files[i]; if (stats_p) @@ -16688,10 +16676,18 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink, multifile_mode = MULTIFILE_MODE_FI; for (cu = alt_first_cu; cu; cu = cu->cu_next) alt_clear_dups (cu->cu_die); - ret |= dwz (file, NULL, &resa[i]); + res->ret = dwz (file, NULL, res); } } + for (j = 0; j < workset_size; j++) + { + int i = workset[j]; + struct file_result *res = &resa[i]; + int thisret = res->ret; + ret |= thisret; + } + if (hardlink) update_hardlinks (nr_files, files, resa);