From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.formilux.org (mta1.formilux.org [51.159.59.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C17F746B5; Sun, 21 Sep 2025 07:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.159.59.229 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758441324; cv=none; b=gqSMQ3fjUtHQ1evzEhv0HHgOU8iE2CMiVpqMKXpa0f0XSwD55VvX5J6bA2+iNdI9EEwdbhABkrnCnoDlDjA5KXX0ibECZcwwxLMCHtXP6LekxvmrNXiV36QFGfLYVD0zBasuEN5MiFnt3HDA7eessHRo/68wz+gx2NMVG2TJCbE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758441324; c=relaxed/simple; bh=lKDmDZHl4eHCumYTD88vWQjemvqbC5h5bl4ao4WRI00=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=o/Sdee2120RyRNe4GUwAtW7eYLhtwG90ojollZqcjfN1jRFtlL4I4DiAch/xYexQJVLOUycjn7oBZfeHP8cXG9qSGTkvfBEGZTrGRqtvUKdCTvqApCfMS6eat7Na5pABTzYTIwRKHI5nt34mJOTwE3ZXLRrYXbRz765Szzo5PN8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; dkim=pass (1024-bit key) header.d=1wt.eu header.i=@1wt.eu header.b=DB4Dd6b8; arc=none smtp.client-ip=51.159.59.229 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=1wt.eu header.i=@1wt.eu header.b="DB4Dd6b8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1758441312; bh=qtuWRkILHisXI4pbHnjs5IBitzDy5cn+s0usEaACUk4=; h=From:Message-ID:From; b=DB4Dd6b8tztBECBsHoDwvgsxTvpTO3LN3rTHvuOFbuV7UUv81ZV/TS57SCmDLhsoP L+QmDz5P1gv1qJRuw5BLp6veIeWYt4v/w2phbxq3VN9S/kTOMs72TxCWwPSqpsV6f/ w9noQs2v6lPOnb0mUBvm6XAxtZF3kDTHdK3Fd+jA= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id 005E0C072E; Sun, 21 Sep 2025 09:55:11 +0200 (CEST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 58L7tBjS016692; Sun, 21 Sep 2025 09:55:11 +0200 Date: Sun, 21 Sep 2025 09:55:11 +0200 From: Willy Tarreau To: Benjamin Berg Cc: linux-um@lists.infradead.org, Thomas =?iso-8859-1?Q?Wei=DFschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Benjamin Berg Subject: Re: [PATCH v2 03/11] tools/nolibc/stdio: remove perror if NOLIBC_IGNORE_ERRNO is set Message-ID: <20250921075511.GA16684@1wt.eu> References: <20250919153420.727385-1-benjamin@sipsolutions.net> <20250919153420.727385-4-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250919153420.727385-4-benjamin@sipsolutions.net> User-Agent: Mutt/1.10.1 (2018-07-13) Hi Benjamin, On Fri, Sep 19, 2025 at 05:34:12PM +0200, Benjamin Berg wrote: > From: Benjamin Berg > > There is no errno variable when NOLIBC_IGNORE_ERRNO is defined. As such, > the perror function does not make any sense then and cannot compile. > > Fixes: acab7bcdb1bc ("tools/nolibc/stdio: add perror() to report the errno value") > Signed-off-by: Benjamin Berg > Acked-by: Thomas Weißschuh > --- > tools/include/nolibc/stdio.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h > index 7630234408c5..c512159b8374 100644 > --- a/tools/include/nolibc/stdio.h > +++ b/tools/include/nolibc/stdio.h > @@ -597,11 +597,13 @@ int sscanf(const char *str, const char *format, ...) > return ret; > } > > +#ifndef NOLIBC_IGNORE_ERRNO > static __attribute__((unused)) > void perror(const char *msg) > { > fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno); > } > +#endif Please instead place the ifndef inside the function so that code calling perror() continues to build. The original goal of that macro was to further shrink programs at the expense of losing error details. But we should be able to continue to build working programs with that macro defined. There's nothing hard set in stone regarding this but here it's easy to preserve a working behavior by having something like this for example: static __attribute__((unused)) void perror(const char *msg) { +#ifdef NOLIBC_IGNORE_ERRNO + fprintf(stderr, "%s\n", (msg && *msg) ? msg : "unknown error"); +#else fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno); +#endif } thanks! Willy