From patchwork Fri Nov 4 21:40:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 59972 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DEEFD385828C for ; Fri, 4 Nov 2022 21:40:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEEFD385828C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667598037; bh=ggHeREvqSp4gXhTL0jKCdWO7ta3VbvqoC/iNrl0Ge1E=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=MLLmcbv4u1auzF+c3FRWg6PyzkpgCw84KZ+cJDvEGbheAA81vV6CMXW06dWNphZWI WKngetCiSVy3ReVbFpxSKb6taqZ6N0I8Wq3BxKmELKOUI2LzlA39aNYghD8O55f3s2 /6Jya8Xh+FQR5njWCED5639oWQ9rH07+ZFBsGVjI= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D31133858421 for ; Fri, 4 Nov 2022 21:40:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D31133858421 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-o1-gkJPoPLyaIDbK3yBH4Q-1; Fri, 04 Nov 2022 17:40:26 -0400 X-MC-Unique: o1-gkJPoPLyaIDbK3yBH4Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26A1585A5A6 for ; Fri, 4 Nov 2022 21:40:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.22.17.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB6EB492B0D; Fri, 4 Nov 2022 21:40:25 +0000 (UTC) To: elfutils-devel@sourceware.org Subject: [COMMITTED] debuginfod_find_section: Always update rc with most recent error code Date: Fri, 4 Nov 2022 17:40:18 -0400 Message-Id: <20221104214018.718373-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aaron Merey via Elfutils-devel From: Aaron Merey Reply-To: Aaron Merey Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" debuginfod_find_section may attempt to download both the debuginfo and executable matching the given build-id. If neither of these files can be found, update rc to ensure that we always return an accurate error code in this case. Signed-off-by: Aaron Merey --- debuginfod/ChangeLog | 5 +++++ debuginfod/debuginfod-client.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 4d576cae..5678002a 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,8 @@ +2022-11-04 Aaron Merey + + * debuginfod-client.c (debuginfod_find_section): Ensure rc + is always updated with the most recent error code. + 2022-11-03 Frank Ch. Eigler * debuginfod.cxx (handle_buildid): Correctly manage lifetime diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index f48e32cc..99da05ef 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -1944,7 +1944,8 @@ debuginfod_find_section (debuginfod_client *client, if (rc == -EEXIST) { - /* The section should be found in the executable. */ + /* Either the debuginfo couldn't be found or the section should + be in the executable. */ fd = debuginfod_find_executable (client, build_id, build_id_len, &tmp_path); if (fd > 0) @@ -1952,6 +1953,9 @@ debuginfod_find_section (debuginfod_client *client, rc = extract_section (fd, section, tmp_path, path); close (fd); } + else + /* Update rc so that we return the most recent error code. */ + rc = fd; } free (tmp_path);