From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C005F3858D28 for ; Fri, 11 Aug 2023 12:15:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C005F3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691756141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GVWlobel8m0/X28BrId+n2r7rZ9u9UGJkjiB2Sqtv0g=; b=D/hiJnLQJMnsMXDrXgr4NSbmHd8rMcd7pNCngwvGnRljxtVNqZczOC1PbAtTOXZb4jLyC0 G6O/8DYypfXVJsfE4CHGwb5SGR5HsqxBNaNc+2tHTBbv/sc8u3fL4ni69bediDpKjDIFYE EKfU74OB7LtINI6jvEDsivlOXQY90lE= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-484-2tlDpKVzN_mLBYylLnh_Xg-1; Fri, 11 Aug 2023 08:15:40 -0400 X-MC-Unique: 2tlDpKVzN_mLBYylLnh_Xg-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2b9f0b7af1cso20849451fa.3 for ; Fri, 11 Aug 2023 05:15:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691756138; x=1692360938; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GVWlobel8m0/X28BrId+n2r7rZ9u9UGJkjiB2Sqtv0g=; b=Pgsy/VxNW26dVbtoClltIYxJJTeIec86vIbOGcmyb3DBlcRV4B/EpDe96ZTYBWMm1q gEGAg1ya1JA4Tkk5VlmvSJHBeP9iPhcQW3ygxJBBsi/Ls3XMWbJp8Py/ZQjiDLruUk+F BWxpjnbgkqONw6bzDm0wwMKJqiRbh54h3aU1Lv+/y3tBaysp4//6070pyu98mg6oKZPm WbjbfTEvpppKzR5ygixXWtgzznlK5zvHyD45Cpy4QUgHqTxq1ZOzVnEg8sNJJum2Pfo4 FcJv+Oxk6igZgfLqYiI47GfPAzwAnICWbgiDaJtwIklgHFfH0rU29bF6TG2fH16SSCE5 311w== X-Gm-Message-State: AOJu0Yw1DSJycuibhrS6gUoHqUs436uOjNfh6C7zBGJSZ5skxdDnw7o5 KCpgcQy3WAYuZ2I8+QEU+3J7pItjmczYtkY1Dca63IgVAh3t0rzhDCYsE1JrgGJjwv3gw3gLI/M CDNPuMFJJvlLigNvH0x3oWg== X-Received: by 2002:a2e:9850:0:b0:2b9:dfd1:3808 with SMTP id e16-20020a2e9850000000b002b9dfd13808mr1499754ljj.25.1691756138736; Fri, 11 Aug 2023 05:15:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwgMnESs+cHnsxNH82E8lL/i/R01gNl+MmgLcXmv0IW1jenJcYRbv14v2dpfpIDtMSIGlyFw== X-Received: by 2002:a2e:9850:0:b0:2b9:dfd1:3808 with SMTP id e16-20020a2e9850000000b002b9dfd13808mr1499732ljj.25.1691756138350; Fri, 11 Aug 2023 05:15:38 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id 8-20020a05600c228800b003fbcf032c55sm7975086wmf.7.2023.08.11.05.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 05:15:37 -0700 (PDT) From: Andrew Burgess To: Alan Modra , binutils@sourceware.org, gdb-patches@sourceware.org Subject: Re: gdb: warn unused result for bfd IO functions In-Reply-To: References: Date: Fri, 11 Aug 2023 13:15:36 +0100 Message-ID: <87350pepw7.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.8 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_H4,RCVD_IN_MSPIKE_WL,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 List-Id: Alan Modra via Binutils writes: > From 3dd00a9f25bc78028ba4b3820b45d34f51c4a25d Mon Sep 17 00:00:00 2001 > From: Alan Modra > Date: Wed, 9 Aug 2023 09:58:36 +0930 > Subject: > > This fixes the compilation warnings introduced by my bfdio.c patch. > > The removed bfd_seeks in coff_symfile_read date back to 1994, commit > 7f4c859520, prior to which the file used stdio rather than bfd to read > symbols. Since it now uses bfd to read the file there should be no > need to synchronise to bfd's idea of the file position. I also fixed > a potential uninitialised memory access. > > OK to apply? I had a look through, this all looks OK, except I think we can easily avoid adding a new 'goto' with the patch below. If you're happy to take this change then: Approved-By: Andrew Burgess Thanks, Andrew --- diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index 34360eb72f1..0d76ebdbfce 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -343,30 +343,29 @@ read_pe_exported_syms (minimal_symbol_reader &reader, || strcmp (target, "pei-i386") == 0 || strcmp (target, "pe-arm-wince-little") == 0 || strcmp (target, "pei-arm-wince-little") == 0); + + /* Possibly print a debug message about DLL not having a valid format. */ + auto maybe_print_debug_msg = [&] () -> void { + if (debug_coff_pe_read) + gdb_printf (gdb_stdlog, _("%s doesn't appear to be a DLL\n"), + bfd_get_filename (dll)); + }; + if (!is_pe32 && !is_pe64) - { - /* This is not a recognized PE format file. Abort now, because - the code is untested on anything else. *FIXME* test on - further architectures and loosen or remove this test. */ - notdll: - if (debug_coff_pe_read) - gdb_printf (gdb_stdlog, _("%s doesn't appear to be a DLL\n"), - bfd_get_filename (dll)); - return; - } + return maybe_print_debug_msg (); /* Get pe_header, optional header and numbers of export entries. */ bool fail = false; pe_header_offset = pe_get32 (dll, 0x3c, &fail); if (fail) - goto notdll; + return maybe_print_debug_msg (); opthdr_ofs = pe_header_offset + 4 + 20; if (is_pe64) num_entries = pe_get32 (dll, opthdr_ofs + 108, &fail); else num_entries = pe_get32 (dll, opthdr_ofs + 92, &fail); if (fail) - goto notdll; + return maybe_print_debug_msg (); if (num_entries < 1) /* No exports. */ return; @@ -381,13 +380,13 @@ read_pe_exported_syms (minimal_symbol_reader &reader, export_opthdrsize = pe_get32 (dll, opthdr_ofs + 100, &fail); } if (fail) - goto notdll; + return maybe_print_debug_msg (); nsections = pe_get16 (dll, pe_header_offset + 4 + 2, &fail); secptr = (pe_header_offset + 4 + 20 + pe_get16 (dll, pe_header_offset + 4 + 16, &fail)); if (fail) - goto notdll; + return maybe_print_debug_msg (); expptr = 0; export_size = 0; @@ -454,7 +453,7 @@ read_pe_exported_syms (minimal_symbol_reader &reader, if (fail || bfd_seek (dll, secptr1 + 0, SEEK_SET) != 0 || bfd_read (sec_name, SCNNMLEN, dll) != SCNNMLEN) - goto notdll; + return maybe_print_debug_msg (); sec_name[SCNNMLEN] = '\0'; sectix = read_pe_section_index (sec_name); @@ -495,7 +494,7 @@ read_pe_exported_syms (minimal_symbol_reader &reader, if (bfd_seek (dll, expptr, SEEK_SET) != 0 || bfd_read (expdata, export_size, dll) != export_size) - goto notdll; + return maybe_print_debug_msg (); erva = expdata - export_rva; nexp = pe_as32 (expdata + 24);