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 80D5D5A004E for ; Wed, 19 Jun 2024 10:25:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718785555; 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=gP3d1luTFTev0iyanFbVrBcpeu8EfFvi0HpWbQPjTao=; b=dpUZ/YpWSxX/1WeNmqCCrBvbrH0JM/MQh/K7rVjLn/wfR8Vtfr2+sI/qEADGJVoSioYWD3 iaPjwwAurEcs1s4Hl8FSr4QTjsV78yR1ppF1OABnd1BQDvI7wQ33qbweO9P/xccgtwGj0e qSvE/1OXz1ravr+zT1OjcOssd7RSN6w= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-209-xFRDeKtfO2uUgozd1pQZJQ-1; Wed, 19 Jun 2024 04:25:54 -0400 X-MC-Unique: xFRDeKtfO2uUgozd1pQZJQ-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-4406476507cso71644201cf.3 for ; Wed, 19 Jun 2024 01:25:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718785554; x=1719390354; 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=gP3d1luTFTev0iyanFbVrBcpeu8EfFvi0HpWbQPjTao=; b=kHWu6FIY7vcEGwrTWS+ETfWB9VsPCdQdm7uFtMLLQEQRgSExI0KK0yzrJzjcX+XyvP GBq6RQlpO3ZHBsDJgmypSp7iqmhscI2Yp/WS5VBmUw9CkptNHfTmd+dXCMq2fRFOexGt zA7X4m06DskNNT/PH5z+TzOVjVfO/jyyq+q0yM60+lzjNyLzHvzDAITMyF10EoqsI6Or Dh8FRv2FsiGGZFsLuZ2sgd5kT0g5A+q+9UR9RlUpy8wlx30wVuKlbjoTYYik4Fz+i2mD 7SWFg+eMjWJcmhX4O5kJwcPtuTAiRBMP2Sw1EiUrrDAWy/B7xqNpKrUx1lu2yU2hpysF sxCg== X-Gm-Message-State: AOJu0YybX8uL3LBjMEYERRZee43CxgSYcEb9I2ton4h8ZrL8r7zLJEvx e5rjM4dkzbrnRmSmPt8elhnsCPoVSBjYE7uUYI1V91nkx6tgoJvSxx9qVkDp+4QDJGBWgFsf6/W YLOj/KUHJdxzrJJrFloCM2IvRK6cBbYZopSCv+W6Glf9YatBxWA== X-Received: by 2002:ac8:5d07:0:b0:440:4cf9:56b3 with SMTP id d75a77b69052e-444a79c7e52mr20294281cf.25.1718785553780; Wed, 19 Jun 2024 01:25:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjOPSH0GF/b+HVBpYeQBU+PXCEwXYNxwQDsrhgBUg+CWuYK7mWx8IbgLh97F2Yva/b1LPBeg== X-Received: by 2002:ac8:5d07:0:b0:440:4cf9:56b3 with SMTP id d75a77b69052e-444a79c7e52mr20294081cf.25.1718785553246; Wed, 19 Jun 2024 01:25:53 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-441ef3d96e8sm63887571cf.1.2024.06.19.01.25.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2024 01:25:52 -0700 (PDT) Date: Wed, 19 Jun 2024 10:25:17 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 4/6] log: Add _perror() logging function variants Message-ID: <20240619102509.2a1ecebf@elisabeth> In-Reply-To: References: <20240617120319.1206857-1-sbrivio@redhat.com> <20240617120319.1206857-5-sbrivio@redhat.com> <20240618080216.2d873da2@elisabeth> 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: DCUO62ADKWCXWTI6SVF6A4F5P7TIU63H X-Message-ID-Hash: DCUO62ADKWCXWTI6SVF6A4F5P7TIU63H 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:11:51 +1000 David Gibson wrote: > On Tue, Jun 18, 2024 at 08:02:16AM +0200, Stefano Brivio wrote: > > On Tue, 18 Jun 2024 10:46:36 +1000 > > David Gibson wrote: > > > > > On Mon, Jun 17, 2024 at 02:03:17PM +0200, Stefano Brivio wrote: > > > > In many places, we have direct perror() calls, which completely bypass > > > > logging functions and log files. > > > > > > > > They are definitely convenient: offer similar convenience with > > > > _perror() logging variants, so that we can drop those direct perror() > > > > calls. > > > > > > > > Signed-off-by: Stefano Brivio > > > > > > Hm, for anything bigger than like a screenful of code, I generally > > > find an explicit message with strerror(errno) more useful than > > > perror() or equivalents, but I guess if you think these are useful. > > > > Okay, yes, it probably makes sense to have more descriptive messages as > > you suggest in the comment to 5/6, but even then, we still have a lot > > of cases like this one (from 6/6): > > > > - warn("lseek() failed on /proc/net file: %s", strerror(errno)); > > + warn_perror("lseek() failed on /proc/net file"); > > > > where these _perror() variants make for tidier code, I find, regardless > > of the error message itself. > > Eh, I mildly prefer the first variant. It is slightly longer, but > makes it very clear where the strerror piece is going to appear in the > context of the whole message. It's not a strong preference, though. Well, it depends. If you're used to perror() it's obvious where the error description will appear, and it's actually faster for me to read something called "_perror" than %s plus the argument. Plus we can save a few lines like that and substantially improve readability in some cases: if (prctl(PR_CAPBSET_DROP, i, 0, 0, 0) && errno != EINVAL && errno != EPERM) - die("Couldn't drop cap %i from bounding set: %s", - i, strerror(errno)); + die_perror("Couldn't drop cap %i from bounding set", i); -- Stefano