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 66EB85A004E for ; Thu, 25 Jul 2024 13:27:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721906868; 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=1LPrkqu+1gNE6NqiPDIi+0JpEmslw/MCXbWu4G/bAlU=; b=BUTkeh5LMNv/WGDr5QboX6jj+S1BL84J+RRt4TO9N2NLcuo5DKxF3w6APbmIHzLDGLSD8Y +k/Ih/zLcu7uV4NpSSyFBYN4XHXUHAm0GrdSK+Vos3hTAvFpQ6mZTaDgC57gZtrbjNgFhE YgAj+4Hk/FeFb/lWkB6ekxdrS2uWc7c= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-344-nKDzu1PaPrqFwR36CsTdfQ-1; Thu, 25 Jul 2024 07:27:46 -0400 X-MC-Unique: nKDzu1PaPrqFwR36CsTdfQ-1 Received: by mail-ua1-f72.google.com with SMTP id a1e0cc1a2514c-8204c69327fso241263241.2 for ; Thu, 25 Jul 2024 04:27:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721906865; x=1722511665; 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=1LPrkqu+1gNE6NqiPDIi+0JpEmslw/MCXbWu4G/bAlU=; b=qic/FjFlS2Ppu82jDKOAvsnbGl1yajCqE/c4NvpiIVor+q+BW6FWbDY/rJ7/nvsYoL WSAZMrq2vXNg9iOH4SD5gsNR/QRzWvpfAHGJOTusL2AXcgauM2nWshYRKeuWdt6Z8dnk aN5h/1xskjTIFn8Oeu3F6iINLZoTxo4H/YzQRY0QRmw9E097hnlu2NHlTPuOTiAYSn2T 4JkF7himmLIN0kAZS42K4VIg5UIe1vkzPZOA0c0nuGz60J9z7o4ITXxKX+b1Z1iSkGmm 9mIjmjs44Dc1z+JcxjylOKshRYRQeTXtx3QhG+s92PUuZ/FLPWHYHTC6Xk9FesKjcN1g 3nQA== X-Gm-Message-State: AOJu0Yy62pHIq+PTefr+xbZfK5cFmncqXD+dIp3kPd/cwHMO2cYuOmew Nh9vSHTELegFCRrqJgOP/2ZSOh2XC6GViHB91aqP/vcmD5wN81jokEgRuGFHcoR0Butw51VFIxt St6gdOs6pudGhdB3mN1bJOGHkfPW/WJ4hZQDYs4B8bLwnz1JsD3cppCgRnO7L X-Received: by 2002:a05:6102:3e0d:b0:48f:e57a:e2f6 with SMTP id ada2fe7eead31-493d99b3f4fmr2309674137.1.1721906864797; Thu, 25 Jul 2024 04:27:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAlGN/BXCQ2pEFQp1Arj/bf1MS2BnJCnnmRTaPuVOocdUBpT7UnJSPC7vSv3YoPjPxTh3QEg== X-Received: by 2002:a05:6102:3e0d:b0:48f:e57a:e2f6 with SMTP id ada2fe7eead31-493d99b3f4fmr2309645137.1.1721906864254; Thu, 25 Jul 2024 04:27:44 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1d7444c9csm68970585a.119.2024.07.25.04.27.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2024 04:27:43 -0700 (PDT) Date: Thu, 25 Jul 2024 13:27:09 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 03/11] log: Drop newlines in the middle of the perror()-like messages Message-ID: <20240725132701.2491756f@elisabeth> In-Reply-To: References: <20240724215021.3366863-1-sbrivio@redhat.com> <20240724215021.3366863-4-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: N5Y4H3JRZ6QTJLOSFVG2WAQNON5EI7SE X-Message-ID-Hash: N5Y4H3JRZ6QTJLOSFVG2WAQNON5EI7SE 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 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 Thu, 25 Jul 2024 13:26:47 +1000 David Gibson wrote: > On Wed, Jul 24, 2024 at 11:50:09PM +0200, Stefano Brivio wrote: > > Calling vlogmsg() twice from logmsg_perror() results in this beauty: > > > > $ ./pasta -i foo > > Invalid interface name foo > > : No such device > > > > because the first part of the message, corresponding to the first > > call, doesn't end with a newline, and vlogmsg() adds it. > > > > 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. > > > > Signed-off-by: Stefano Brivio > > 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. 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). 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). > But, I don't actually care that much so > > Reviewed-by: David Gibson -- Stefano