From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id F12051F5AE for ; Fri, 21 May 2021 09:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236557AbhEUJfn (ORCPT ); Fri, 21 May 2021 05:35:43 -0400 Received: from cloud.peff.net ([104.130.231.41]:33172 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236053AbhEUJfm (ORCPT ); Fri, 21 May 2021 05:35:42 -0400 Received: (qmail 2869 invoked by uid 109); 21 May 2021 09:34:19 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 21 May 2021 09:34:19 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 7825 invoked by uid 111); 21 May 2021 09:34:21 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Fri, 21 May 2021 05:34:21 -0400 Authentication-Results: peff.net; auth=none Date: Fri, 21 May 2021 05:34:18 -0400 From: Jeff King To: Junio C Hamano Cc: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , git@vger.kernel.org, Denton Liu , Jeff Hostetler , Johannes Schindelin Subject: Re: [PATCH v3] trace2: refactor to avoid gcc warning under -O3 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, May 21, 2021 at 07:08:11AM +0900, Junio C Hamano wrote: > Jeff King writes: > > >> @@ -287,7 +285,7 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst, > >> if (tr2_dst_want_warning()) > >> warning("trace2: could not connect to socket '%s' for '%s' tracing: %s", > >> path, tr2_sysenv_display_name(dst->sysenv_var), > >> - strerror(e)); > >> + strerror(errno)); > > > > We expect the value of errno to persist across tr2_dst_want_warning() > > and tr2_sysenv_display_name() here. The former may call getenv() and > > atoi(). I think that's probably fine, but if we wanted to be really > > paranoid, we'd have to preserve errno manually here, too. > > Being "really paranoid" consistently within the file would mean a > change like the attached, I would think, on top of what was posted. > > Or tr2_dst_want_warning() and tr2_sysenv_display_name() can be > taught to preserve errno like tr2_dst_dry_uds_connect() was taught > to do so by the patch under discussion, which may reduce the amount > of apparent change, but constantly moving the contents of errno > around just in case we later might want to use its value feels > dirty. > > I dunno. > > trace2/tr2_dst.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) Ah, yeah. I didn't look to see if there were existing cases of the same thing. I could go either way on this kind of saved_errno thing in general (the tr2 functions called in between are really quite unlikely to set errno (I am not even sure if getenv() and atoi() can, so this really might just be future-proofing in case those tr2 functions get more complicated). But seeing that there are other cases of the same, I definitely think it is not something that should be in Ævar's patch. It is a cleanup we could do on top if we cared to. -Peff