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.133.124]) by passt.top (Postfix) with ESMTP id B36115A004E for ; Wed, 19 Jun 2024 10:38:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718786327; 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=It3TqA7rVV/aTb7sdCU8tl3FwFIJYpkG6rUmiHtK94o=; b=bQZqmr1mDZ78ir1McUugDidHfQCUOBQKsRoHHhWU9nXgfTpwNZRw4l1RYkyAo+5BzHhCgF vDAK1cZpivK8lp1ZnxVhJtlnXaYwtJiuKLnShqtQYDpPZ6PS3RZcYYW8Oll6Npn6uG2lld vglb5wDlGNDq4cfTJZ9NaC99hfHb6qE= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-ZX4KC-XKNl2TiIqwaXWCbQ-1; Wed, 19 Jun 2024 04:38:46 -0400 X-MC-Unique: ZX4KC-XKNl2TiIqwaXWCbQ-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-62f8a1b2969so130159767b3.3 for ; Wed, 19 Jun 2024 01:38:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718786324; x=1719391124; 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=It3TqA7rVV/aTb7sdCU8tl3FwFIJYpkG6rUmiHtK94o=; b=db6658yEkk009wetXCGftRME02Sm8iN0LXeyZQUHPUDCBX2XNSSOU8XvZQpnAzvYhv abK0Xw77Bf7QcVjZTeMtrc7xUCClJC0DUkqFJD4KzLhfQMEmtHogV4w3Dbh1LlUoPfvV Mo375jtLZLTSSWEZSDBshOL2RJ1VkZ0DosoDEXtSMboSMeYtfIhIYWRwyUJxxHBu81+n K8F4B8psPabj4KMQ/o5ima7RZ2zcI+5iEyKP0d2GaGS9VbanL0GktUd1sxlgY0GrSg0k 7DLiCOHtB/6tLJFNwik1KDgfUcis/9a/JDY5th68uSA4W9ZQ8qKsjbNQtmzutT/Sm8TD U+Fw== X-Gm-Message-State: AOJu0Yzxdx9FK5KPw9shlFcSJ7ikA4a7jIN3l4Vbmr6kjauiV38H5mzc /83z93dQrit6bGN8FPFtrCBREu5bO9NEewyIVkb97mnvaw7tES1EhST6jsCm3bEsnvV0+WWAKfu N6vHDk2x1FrAtkU+W1pzXrOKaLflYYmrACj4ujKgbfoiqG4FmlAsxAm9Qjt1R X-Received: by 2002:a0d:d342:0:b0:61a:ca09:dae3 with SMTP id 00721157ae682-63a8e4bb138mr22313737b3.26.1718786324035; Wed, 19 Jun 2024 01:38:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdW/jxF+rMrCI1Qqh4HwE7LsvfSW2DJFSlNUHKERvZdNNZfqfCtM2eQDV+CaN7/Cd+/DU/Vg== X-Received: by 2002:a0d:d342:0:b0:61a:ca09:dae3 with SMTP id 00721157ae682-63a8e4bb138mr22313647b3.26.1718786323578; Wed, 19 Jun 2024 01:38:43 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b50af4c26bsm965946d6.102.2024.06.19.01.38.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2024 01:38:43 -0700 (PDT) Date: Wed, 19 Jun 2024 10:38:08 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 4/6] log: Add _perror() logging function variants Message-ID: <20240619103801.3a6088cd@elisabeth> In-Reply-To: References: <20240618071427.1544869-1-sbrivio@redhat.com> <20240618071427.1544869-5-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: TABH7MSGAIAOQ6VYF4VKYXIC7QM5FJH5 X-Message-ID-Hash: TABH7MSGAIAOQ6VYF4VKYXIC7QM5FJH5 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:21:56 +1000 David Gibson wrote: > On Tue, Jun 18, 2024 at 09:14:25AM +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 > > --- > > log.c | 21 +++++++++++++++++++++ > > log.h | 21 +++++++++++++++++---- > > 2 files changed, 38 insertions(+), 4 deletions(-) > > > > diff --git a/log.c b/log.c > > index 5853496..9ddc58c 100644 > > --- a/log.c > > +++ b/log.c > > @@ -79,6 +79,11 @@ void vlogmsg(int pri, const char *format, va_list ap) > > } > > } > > > > +/** > > + * logmsg() - vlogmsg() wrapper for variable argument lists > > + * @pri: Facility and level map, same as priority for vsyslog() > > + * @format: Message > > + */ > > void logmsg(int pri, const char *format, ...) > > { > > va_list ap; > > @@ -88,6 +93,22 @@ void logmsg(int pri, const char *format, ...) > > va_end(ap); > > } > > > > +/** > > + * logmsg_perror() - vlogmsg() wrapper with perror()-like functionality > > + * @pri: Facility and level map, same as priority for vsyslog() > > + * @format: Message > > + */ > > +void logmsg_perror(int pri, const char *format, ...) > > +{ > > + va_list ap; > > + > > + va_start(ap, format); > > + vlogmsg(pri, format, ap); > > + va_end(ap); > > + > > + logmsg(pri, ": %s", strerror(errno)); > > The vlogmsg() above could invoke syscalls which clobber errno, so you > need to save it beforehand. Oops, nice catch. -- Stefano