From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by sourceware.org (Postfix) with ESMTP id 440083871026 for ; Tue, 17 Mar 2020 15:47:28 +0000 (GMT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-6vh0mKyaNPWqk0JaBIivxw-1; Tue, 17 Mar 2020 11:47:26 -0400 X-MC-Unique: 6vh0mKyaNPWqk0JaBIivxw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFBD718C8C03; Tue, 17 Mar 2020 15:47:25 +0000 (UTC) Received: from psique.yyz.redhat.com (unused-10-15-17-54.yyz.redhat.com [10.15.17.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 433AD10027A8; Tue, 17 Mar 2020 15:47:25 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Pedro Alves , Tom Tromey , Kevin Buettner , Sergio Durigan Junior Subject: [PATCH v2 2/5] Don't reset errno/bfd_error on 'throw_perror_with_name' Date: Tue, 17 Mar 2020 11:47:16 -0400 Message-Id: <20200317154719.2078283-3-sergiodj@redhat.com> In-Reply-To: <20200317154719.2078283-1-sergiodj@redhat.com> References: <20200226200542.746617-1-sergiodj@redhat.com> <20200317154719.2078283-1-sergiodj@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-25.2 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2020 15:47:29 -0000 Even though this patch is not necessarily needed by the main feature, I think it's a good idea to have it. We currently have this code on 'throw_perror_with_name': /* I understand setting these is a matter of taste. Still, some people may clear errno but not know about bfd_error. Doing this here is not unreasonable. */ bfd_set_error (bfd_error_no_error); errno =3D 0; git blame tells me that this piece of code is pretty old; the commit that "introduced" it is: commit c906108c21474dfb4ed285bcc0ac6fe02cd400cc Author: Stan Shebs Date: Fri Apr 16 01:35:26 1999 +0000 Initial creation of sourceware repository so yeah... If we go to the POSIX specification for 'perror', it doesn't really say anything about whether errno should be preserved or not. It does, however, say that 'perror's messages should be the same as those returned by 'strerror', and 'strerror' is not supposed to alter errno if the call is successful. Maybe when our wrapper was written it was OK to modify errno, I don't know. But I'd like to propose that we stick to POSIX in this case. gdb/ChangeLog: yyyy-mm-dd Sergio Durigan Junior =09* utils.c (throw_perror_with_name): Don't reset =09errno/bfd_error. --- gdb/utils.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/gdb/utils.c b/gdb/utils.c index 0b470120a2..df8add1afa 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -595,12 +595,6 @@ throw_perror_with_name (enum errors errcode, const cha= r *string) { std::string combined =3D perror_string (string); =20 - /* I understand setting these is a matter of taste. Still, some people - may clear errno but not know about bfd_error. Doing this here is not - unreasonable. */ - bfd_set_error (bfd_error_no_error); - errno =3D 0; - throw_error (errcode, _("%s."), combined.c_str ()); } =20 --=20 2.24.1