From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 5AAD35A004E for ; Wed, 19 Jun 2024 10:37:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718786249; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UnDuHBkt6fZTqu/j9WN6zpENxlHNi3EsdCJ14pmUbG4=; b=QJT7eTDs0oMD3Rj28L8sYupl7t93cnAh1klJQIf76Rd0JNv98GyYrMHV+4WhpdnzhnkwTj Pb8Ha7dPsroi3321s2c1KBxOFKLKIZu0qzZghG4BRyncWD6p66c8Ka83l4eSwlciWF3g0u NjMnwMDxWhRHAEk/46XchM8xJ11l/KA= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-YSGL_qp3Mb-M2U-_e0q90w-1; Wed, 19 Jun 2024 04:37:27 -0400 X-MC-Unique: YSGL_qp3Mb-M2U-_e0q90w-1 Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-80b8b3d3b31so2906412241.1 for ; Wed, 19 Jun 2024 01:37:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718786247; x=1719391047; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=UnDuHBkt6fZTqu/j9WN6zpENxlHNi3EsdCJ14pmUbG4=; b=aCWV0L7Gmb21zcv9DLUx0hKgneV0ESlfBNDA0ORRKex89AWfknXyBcNliGk2KParHC 1C0AzOQGMHNYzQE31lMPuN2ZyV1PiIfR5MGXTIiLt5P7zH0yPS3AxuWXm3w18EdUpo9n Zmv0mXhAcKuAOWactnt5AS0Sr9Spbu0zZF9SvsLantpiMOE57Str+PnxTOXaZ36wAC/s 5Qks2wvkzUCfh+FlRM+V+Q80j8m9XaQvDU/aXWlrzib6pwOYHngoSnU36BWlZzQioafK DSpXLwZglVqFmuDd3xqvk+uETTEb/73hCMDwTwdtDilFmLXV1r5An99+boo9GRfbXCAa vfGA== X-Gm-Message-State: AOJu0YyNREv4NglAv/rzBYKL9VGUREMPfaLXyXi9HpJrqiOusz8wPK/K HFxqeUBsGJ84HVMEwRYe+iCaYE7VwfY3ctUrnj7aKoiGC4p0o6oF2lu0knbCwTXPiUumsyvxa0i FNbLawPiShsl1MR9vofwHoLK2HtC/bW/Osu3flhiNUyQdEZbbTQ== X-Received: by 2002:a67:eb88:0:b0:48d:b02e:5ca2 with SMTP id ada2fe7eead31-48f13097552mr2101942137.24.1718786246693; Wed, 19 Jun 2024 01:37:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGThrH73VZ3SGi26bSRFeAgMCRiKkNtyiDBjACxMng4ToVKolDPuA/S8Vf/IefWJfSQizDQKw== X-Received: by 2002:a67:eb88:0:b0:48d:b02e:5ca2 with SMTP id ada2fe7eead31-48f13097552mr2101930137.24.1718786246274; Wed, 19 Jun 2024 01:37:26 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798aaecc068sm588867585a.34.2024.06.19.01.37.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2024 01:37:25 -0700 (PDT) Date: Wed, 19 Jun 2024 10:36:50 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 6/6] treewide: Replace strerror() calls Message-ID: <20240619103643.6f7a8eba@elisabeth> In-Reply-To: References: <20240618071427.1544869-1-sbrivio@redhat.com> <20240618071427.1544869-7-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 2QMTAWNPRJTJ35M7SAP2F76BCPTCJPLQ X-Message-ID-Hash: 2QMTAWNPRJTJ35M7SAP2F76BCPTCJPLQ X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Yalan Zhang X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 19 Jun 2024 12:29:06 +1000 David Gibson wrote: > On Tue, Jun 18, 2024 at 09:14:27AM +0200, Stefano Brivio wrote: > > Now that we have logging functions embedding perror() functionality, > > we can make _some_ calls more terse by using them. In many places, > > the strerror() calls are still more convenient because, for example, > > they are used in flow debugging functions, or because the return code > > variable of interest is not 'errno'. > > > > While at it, convert a few error messages from a scant perror style > > to proper failure descriptions. > > > > Signed-off-by: Stefano Brivio > > --- > > conf.c | 31 +++++++++++++++++-------------- > > fwd.c | 2 +- > > isolation.c | 28 +++++++++++----------------- > > log.c | 2 +- > > netlink.c | 4 ++-- > > passt.c | 12 ++++-------- > > pasta.c | 32 ++++++++++++++++---------------- > > pcap.c | 8 +++----- > > tap.c | 14 +++++++------- > > tcp.c | 24 ++++++++---------------- > > util.c | 12 +++++------- > > 11 files changed, 75 insertions(+), 94 deletions(-) > > > > diff --git a/conf.c b/conf.c > > index 344eb07..2a6f05c 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -461,7 +461,7 @@ static void get_dns(struct ctx *c) > > } > > > > if (line_len < 0) > > - warn("Error reading /etc/resolv.conf: %s", strerror(errno)); > > + warn_perror("Error reading /etc/resolv.conf"); > > close(fd); > > > > out: > > @@ -592,8 +592,8 @@ static unsigned int conf_ip4(unsigned int ifi, > > if (IN4_IS_ADDR_UNSPECIFIED(&ip4->gw)) { > > int rc = nl_route_get_def(nl_sock, ifi, AF_INET, &ip4->gw); > > if (rc < 0) { > > - err("Couldn't discover IPv4 gateway address: %s", > > - strerror(-rc)); > > + errno = -rc; > > I don't love this. Taking a re-entrant bit of code and making it > non-reentrant by bouncing information through a global. I mean, it > works in this case, but still.. Hmm, right, I'll drop this type of change. -- Stefano