From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uTsZORV2mGoT5R8AWB0awg (envelope-from ) for ; Wed, 02 Sep 2026 15:16:37 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=E+baEpyg; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=q3+UsbN4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u0iRvquD; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FrFiq/PO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E42FF1E033; Wed, 02 Sep 2026 15:16:37 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5A5CC1E033 for ; Wed, 02 Sep 2026 15:16:36 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 252494BAE7E3 for ; Wed, 2 Sep 2026 19:16:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 252494BAE7E3 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=E+baEpyg; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=q3+UsbN4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u0iRvquD; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FrFiq/PO Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 0FB404BA79A5 for ; Wed, 2 Sep 2026 19:16:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FB404BA79A5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0FB404BA79A5 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788376569; cv=none; b=onD0QajhZors16NOIzeALLacPem8XJsbItT2y2ELxlykB8JoBIrGA1UGx9g5Hel32L1zhWRuxQKQ5QLwoSm1BUXPe2Dsnr8C5bg2THafsecn7bZ3DAzk6ZSIIs2P5MqesJvAhtmrRrQz0SZNjaIVqEHZk5MP27mAvTmQxzTO4V0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788376569; c=relaxed/simple; bh=X0Yf9DbB0BrzcPJDwzurHfRwDwfVGnRC9gNMMUC64pU=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=u+ExirpDgGQExBXw+UtA2IaG2/lKP89JO10i1NvS+oYaNr79IE7UYhH1ZIM1UZ/IlFqe9ln+wpnlWbRU96OSPKYlyv+Ez8+gbgAvQ0OK3HqDn75IVMt/DAGaP4LtzC4Usuu1XwdMl/XQILnh8ivePD1+oosSTCNbwQefqA+TIQA= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=E+baEpyg; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=q3+UsbN4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u0iRvquD; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FrFiq/PO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FB404BA79A5 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DD3DD1F8B0 for ; Wed, 2 Sep 2026 19:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788376564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=zS1SZd/vH2xs/fg9rnH5p71nphVl084nLdLIOyxQjPI=; b=E+baEpyg9PiTj+Rk2KDqO1g+QagrG6GC84v2TqzHbPyZcv+qKSklGI+tYvz7H4cLru+8EP YVN11HvABR7slGwm+/Q4n1/qAoQOEMso5Q7YYV3Omt+VfErdpfko7p85CCOWaseqXvy2Mv ixyJU8aZnSyjsh7Lyey5ZlWTwniJCgA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788376564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=zS1SZd/vH2xs/fg9rnH5p71nphVl084nLdLIOyxQjPI=; b=q3+UsbN4VHmt/prhK+tFgmpJ4JsVxMe8oeblL2MyHFtpzZ2TyTKY/PpOGBt0NHs5RP+J6C bfnXjOxFS3sOnGAg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=u0iRvquD; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="FrFiq/PO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788376559; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=zS1SZd/vH2xs/fg9rnH5p71nphVl084nLdLIOyxQjPI=; b=u0iRvquDxih6YjAo5b5mvA84hJx7oYkGqU2XJ3vTE5jKmpFAAO5EpUjjHN+CeVi1eDd5aJ ejMXiFMSmfVlSJYCbKnRPMnXtFKqFPgtB9zhbam7dgtFM8bOhH/wehf3jZnoGiiF5fg6CD 6kQYHBjC867ZF/6/bJcY9nRb8jNkhtg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788376559; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=zS1SZd/vH2xs/fg9rnH5p71nphVl084nLdLIOyxQjPI=; b=FrFiq/PO61DW9XH0wEj48K/LPygIxa4qPiBTxcr6i65WRh8Zq09yTRy6EO0OzdOmd6JzNn 2mpzmUOIHzcqtGDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8A701136E6 for ; Wed, 2 Sep 2026 19:15:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id qniyH+91mGotNAAAD6G6ig (envelope-from ) for ; Wed, 02 Sep 2026 19:15:59 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/contrib] Simplify rc usage in cc-with-tweaks.sh Date: Wed, 2 Sep 2026 21:15:59 +0200 Message-ID: <20260902191559.3951565-1-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DD3DD1F8B0 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:mid]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_NONE(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[suse.de:+] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org The usage of the rc variable in gdb/contrib/cc-with-tweaks.sh follows a certain pattern: ... $ egrep '(rc=|\$rc)' gdb/contrib/cc-with-tweaks.sh | grep -v cmp_rc rc=$? [ $rc != 0 ] && exit $rc rc=$? [ $rc != 0 ] && exit $rc rc=${PIPESTATUS[0]} [ "$rc" != 0 ] && exit "$rc" rc=$? [ $rc != 0 ] && exit $rc rc=0 rc=$? [ $rc != 0 ] && exit $rc rc=$? [ $rc != 0 ] && exit $rc rc=$? [ $rc != 0 ] && exit $rc rc=$? [ $rc != 0 ] && exit $rc exit "$rc" ... It is: - set using 'rc=$?' or 'rc=${PIPESTATUS[0]}', and then - used in '[ $rc != 0 ] && exit $rc'. The two exceptions are 'rc=0', and 'exit "$rc"'. Remove the 'rc=0', there's no path reaching it where it's not already 0. Removing the 'exit "$rc"' changes semantics in a cornercase. Consider: ... if true; then rc=0 [ $rc != 0 ] && exit $rc fi exit $rc ... What happens is: - the if block is entered - rc is set to 0 - the test evaluates to 1, so the exit doesn't trigger - the if returns status of last command (1) - script exits with 0 If we remove the exit, we have: - the if block is entered - rc is set to 0 - the test evaluates to 1, so the exit doesn't trigger - the if returns status of last command (1) - script exits with status of last command (1) Fix this using: ... -[ $rc != 0 ] && exit $rc +if [ $rc != 0 ]; then exit $rc; fi ... --- gdb/contrib/cc-with-tweaks.sh | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh index 047c748e165..20f90d9c3ed 100755 --- a/gdb/contrib/cc-with-tweaks.sh +++ b/gdb/contrib/cc-with-tweaks.sh @@ -163,7 +163,7 @@ output_dir="${output_file%/*}" "$@" rc=$? -[ $rc != 0 ] && exit $rc +if [ $rc != 0 ]; then exit $rc; fi if [ ! -f "$output_file" ] then echo "$myname: Internal error: $output_file missing." >&2 @@ -184,7 +184,7 @@ get_tmpdir () if [ "$want_objcopy_compress" = true ]; then $OBJCOPY --compress-debug-sections "$output_file" rc=$? - [ $rc != 0 ] && exit $rc + if [ $rc != 0 ]; then exit $rc; fi fi if [ "$want_index" = true ]; then @@ -212,7 +212,7 @@ if [ "$want_index" = true ]; then rc=${PIPESTATUS[0]} mv "$tmpfile" "$output_file" rm -f "$tmpdir"/*.dwo - [ "$rc" != 0 ] && exit "$rc" + if [ "$rc" != 0 ]; then exit "$rc"; fi fi if [ "$want_index_cache" = true ]; then @@ -221,7 +221,7 @@ if [ "$want_index_cache" = true ]; then -ex "set index-cache enabled on" \ -ex "file $output_file" rc=$? - [ $rc != 0 ] && exit $rc + if [ $rc != 0 ]; then exit $rc; fi fi if [ "$want_dwz" = true ] || [ "$want_multi" = true ]; then @@ -290,11 +290,10 @@ if [ "$want_dwp" = true ]; then | sed -e 's/^.*: //' \ | sort \ | uniq) - rc=0 if [ ${#dwo_files[@]} -ne 0 ]; then $DWP -o "${output_file}.dwp" "${dwo_files[@]}" > /dev/null rc=$? - [ $rc != 0 ] && exit $rc + if [ $rc != 0 ]; then exit $rc; fi rm -f "${dwo_files[@]}" fi fi @@ -313,11 +312,11 @@ if [ "$want_gnu_debuglink" = true ]; then strip "${STRIP_ARGS_STRIP_DEBUG[@]}" "${output_file}" \ -o "${stripped_file}" rc=$? - [ $rc != 0 ] && exit $rc + if [ $rc != 0 ]; then exit $rc; fi strip "${STRIP_ARGS_KEEP_DEBUG[@]}" "${output_file}" \ -o "${debug_file}" rc=$? - [ $rc != 0 ] && exit $rc + if [ $rc != 0 ]; then exit $rc; fi # The .gnu_debuglink is supposed to contain no leading directories. link=$(basename "${debug_file}") @@ -332,7 +331,5 @@ if [ "$want_gnu_debuglink" = true ]; then "${output_file}" ) rc=$? - [ $rc != 0 ] && exit $rc + if [ $rc != 0 ]; then exit $rc; fi fi - -exit "$rc" base-commit: 62b131d7aebdb9921f47656cb0590f99fc31edbf -- 2.51.0