All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Petr Mladek <pmladek@suse.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH next] netfilter: nf_conntrack_h323: Correct indentation when H323_TRACE defined
Date: Fri, 27 Mar 2026 09:51:58 +0000	[thread overview]
Message-ID: <20260327095158.74c87ddf@pumpkin> (raw)
In-Reply-To: <acZM4qwEtWqANece@ashevche-desk.local>

On Fri, 27 Mar 2026 11:24:50 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Thu, Mar 26, 2026 at 10:18:09PM +0000, David Laight wrote:
> > On Thu, 26 Mar 2026 21:24:39 +0100
> > Pablo Neira Ayuso <pablo@netfilter.org> wrote:  
> > > On Thu, Mar 26, 2026 at 08:18:19PM +0000, david.laight.linux@gmail.com wrote:  
> > > > 
> > > > The trace lines are indented using PRINT("%*.s", xx, " ").
> > > > Userspace will treat this as "%*.0s" and will output no characters
> > > > when 'xx' is zero, the kernel treats it as "%*s" and will output
> > > > a single ' ' - which is probably what is intended.
> > > > 
> > > > Change all the formats to "%*s" removing the default precision.
> > > > This gives a single space indent when level is zero.    
> > > 
> > > Do you have a setup using this helper? Or you just found this via
> > > visual inspection?  
> > 
> > Found with grep looking for places which might be affected by 'fixing'
> > the kernel printf code to be POSIX compliant.  
> 
> Do we have the respective test case in printf_kunit?
> 

There are definitely related ones and this comment:

static void
test_string(struct kunit *kunittest)
{
[...]
	/*
	 * POSIX and C99 say that a negative precision (which is only
	 * possible to pass via a * argument) should be treated as if
	 * the precision wasn't present, and that if the precision is
	 * omitted (as in %.s), the precision should be taken to be
	 * 0. However, the kernel's printf behave exactly opposite,
	 * treating a negative precision as 0 and treating an omitted
	 * precision specifier as if no precision was given.
	 *
	 * These test cases document the current behaviour; should
	 * anyone ever feel the need to follow the standards more
	 * closely, this can be revisited.
	 */
	test("    ", "%4.*s", -5, "123456");
[...]
}

I suspect whoever wrote the tests found the code was non-conformant.
But there isn't a comment in the snprintf() code itself.
I've not checked what the kernel code does (I've just written/fixed all
this for nolibc - the kernel will fail the nolibc tests).

	David


  reply	other threads:[~2026-03-27  9:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26 20:18 [PATCH next] netfilter: nf_conntrack_h323: Correct indentation when H323_TRACE defined david.laight.linux
2026-03-26 20:24 ` Pablo Neira Ayuso
2026-03-26 22:18   ` David Laight
2026-03-27  9:24     ` Andy Shevchenko
2026-03-27  9:51       ` David Laight [this message]
2026-03-27  9:47 ` Petr Mladek
2026-03-27 12:55   ` David Laight
2026-03-27 13:11     ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260327095158.74c87ddf@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mhiramat@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.