From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 018485A004E for ; Fri, 26 Jul 2024 03:27:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1721957222; bh=Xji1HXf9qxYy85shfkT6/Y3PSdyz+z/dsPGV7I0mo+I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dE7DQ0tTNDDo9tuQuAmCyEql/FhI4fQTgHAvdVxIXtGMx9nxevYysFHE6LsBrT/x5 ha6y69vnLuOqi8rkP78v/2Ypt/Qr3C5D0gEEckU+kLmJxoG8f7VtDtmkoRXgdPRsMZ VmWtGCkDAXOahzjXXaPhz1fDX6pDAY7284er1zoAMgSlNZzaAZw1EF37bwT51JmSqI QmtsEKj1/AY9+vAuqKjrlZ45DNd27F7WktMY1lHZ0zjGf7aYYDj88/oANiD+9nPWlk E9/fu+ZMz8LgIVMDboJx3aKcP8HlJl5ugw6R2wrCCGEEzYyer/g64ZMb+NJ3aXjms2 z0ejW7i+bpRcQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WVVTy6FbJz4wbr; Fri, 26 Jul 2024 11:27:02 +1000 (AEST) Date: Fri, 26 Jul 2024 10:33:25 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 03/11] log: Drop newlines in the middle of the perror()-like messages Message-ID: References: <20240724215021.3366863-1-sbrivio@redhat.com> <20240724215021.3366863-4-sbrivio@redhat.com> <20240725132701.2491756f@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="toaxmLZHi6Ew5MLf" Content-Disposition: inline In-Reply-To: <20240725132701.2491756f@elisabeth> Message-ID-Hash: V2QOEFT3QP2LK4ZFIZI6TMK5PZGWTN2V X-Message-ID-Hash: V2QOEFT3QP2LK4ZFIZI6TMK5PZGWTN2V X-MailFrom: dgibson@gandalf.ozlabs.org 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 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: --toaxmLZHi6Ew5MLf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 25, 2024 at 01:27:09PM +0200, Stefano Brivio wrote: > On Thu, 25 Jul 2024 13:26:47 +1000 > David Gibson wrote: >=20 > > On Wed, Jul 24, 2024 at 11:50:09PM +0200, Stefano Brivio wrote: > > > Calling vlogmsg() twice from logmsg_perror() results in this beauty: > > >=20 > > > $ ./pasta -i foo > > > Invalid interface name foo > > > : No such device > > >=20 > > > because the first part of the message, corresponding to the first > > > call, doesn't end with a newline, and vlogmsg() adds it. > > >=20 > > > Given that we can't easily append an argument (error description) to > > > a variadic list, add a 'newline' parameter to all the functions that > > > currently add a newline if missing, and disable that on the first call > > > to vlogmsg() from logmsg_perror(). Not very pretty but I can't think > > > of any solution that's less messy than this. > > >=20 > > > Signed-off-by: Stefano Brivio =20 > >=20 > > I think my personal inclination would be to rename all the > > lowest-level functions slightly and remove the newline adding logic > > unconditionally. The create wrappers under the old name which add the > > "\n". I think that can be done in an easy macro, since the "\n" can > > be constant string appended to the format string. Just the special > > paths that need to suppress the newline would call the low level "no > > newline" variants. >=20 > I gave it a try, but the problem is that the "easy macro" needs to be > conditional, depending on whether the newline is there or not: we don't > want to add a newline in case somebody already added it by mistake (or > habit). Well, I mean we could just add the newline and consider it a bug if someone puts one in themselves. > That could probably be done as well with an intermediate function, but > it's getting a bit too complicated (at least for me right now). >=20 > > But, I don't actually care that much so > >=20 > > Reviewed-by: David Gibson >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --toaxmLZHi6Ew5MLf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmai7tQACgkQzQJF27ox 2GfvohAAmFB+VrEyF9mRma9cTkguedKgHNpINS/vaBsV4QF+oIkIUv2ekaRy23GO MXa6a2gnjDsOe5TRpzNl7eNKYS1fl8Kt/Xw8gz5bfS8Awadlet3XicOGclnmCNXO JWOixTrhosqWyxpNxe/c+MvUqow8j7b1EKntrm2MTJm4h/uiBo+MqT//N/BXK0ab R2W/Ztix2+a1Ysbk92paXc+N/78bYULVv2xtTT97vmoPCX1jtemB9XoFXIr+TnA/ 3q0lN8+pIwOzPWh8awXePjb8b25tUcD9gv0fSLeerjM8joHLOp2a4I31i2N7KniP zu9rwmziLUxVzKUmw/U8Nn4p65QDgYS33D6YcNMtPBzAMMbT9jPli8X+x0oqljbC 2s4XQQuOZU2/UMwRhoM4c2qe03wrQYXjdNyxoToFMX7DLr3nEEAnoMuV24iVMcE5 IZrKoqQ1tBGRDOmT/gzs8TlIyzQ40mJA1JpNGN7CVk5J0TnZqa23cxYEFc8QlPdt uviQODF+DqF89Qoe5qHvysP5Rtqx/PSr6GiAn7Q7oH9vCgTGP9VyE4tBTRK31ieI aOOMUWQEcvPhPuK0o7cZ9sDNNbEZX7OFQ9Yx32Xl57i6kNZSPtOPvIgqNZw7Ax/t MzdSXsgKffleRk+hnws1TvL84IqTLh5boL9Ph0gxCgNrFascuKU= =h8cQ -----END PGP SIGNATURE----- --toaxmLZHi6Ew5MLf--