lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aXD5sNXwhnU5ycam@pathway>
Date: Wed, 21 Jan 2026 17:07:12 +0100
From: Petr Mladek <pmladek@...e.com>
To: Tamir Duberstein <tamird@...nel.org>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@...omium.org>,
	Nathan Chancellor <nathan@...nel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
	Bill Wendling <morbo@...gle.com>,
	Justin Stitt <justinstitt@...gle.com>, Kees Cook <kees@...nel.org>,
	linux-kernel@...r.kernel.org, oe-kbuild-all@...ts.linux.dev,
	llvm@...ts.linux.dev, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH v2] printf: convert test_hashed into macro

On Tue 2026-01-20 10:50:09, Tamir Duberstein wrote:
> On Mon, Jan 19, 2026 at 3:21 AM Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:
> >
> > On Fri, Jan 16, 2026 at 11:27:03AM -0500, Tamir Duberstein wrote:
> > > This allows the compiler to check the arguments against the __printf
> >
> > __printf() since it takes parameters, OTOH it's an attribute at the end,
> > so I have no strong opinion on how to spell it.
> >
> > > attribute on __test. This produces better diagnostics when incorrect
> >
> > __test()
> >
> > *This is reference to a function.
> >
> > > inputs are passed.
> >
> > ...
> >
> > > +/*
> > > + * This is a macro so that the compiler can compare its arguments to the
> > > + * __printf attribute on __test. This cannot be a function with a __printf
> > > + * attribute because GCC requires __printf functions to be variadic.
> >
> > As per commit message remarks.
> >
> > > + */
> > > +#define test_hashed(kunittest, fmt, p)                                   \
> > > +     do {                                                             \
> > > +             char buf[PLAIN_BUF_SIZE];                                \
> > > +             plain_hash_to_buffer(kunittest, p, buf, PLAIN_BUF_SIZE); \
> > > +             test(buf, fmt, p);                                       \
> > > +     } while (0)
> >
> > Make sure you used tabs to indent the \:s.
> >
> > ...
> >
> > The downside of a macro is a killing of compile-time type checks.
> 
> This macro still bottoms out in __test() which is a function, so I
> believe it preserves (and enhances, per the commit message)
> compile-time checks.
> 
> I'll send v3 with the changes you requested above.

JFYI, I am fine with this approach.

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ