All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Tamir Duberstein <tamird@kernel.org>
Cc: Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Kees Cook <kees@kernel.org>,
	linux-kernel@vger.kernel.org, oe-kbuild-all@lists.linux.dev,
	llvm@lists.linux.dev, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v2] printf: convert test_hashed into macro
Date: Mon, 19 Jan 2026 10:21:21 +0200	[thread overview]
Message-ID: <aW3pgf4FQHFCC9Bm@smile.fi.intel.com> (raw)
In-Reply-To: <20260116-printf-kunit-printf-attr-v2-1-3dd7fefc3207@kernel.org>

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.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-01-19  8:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16 16:27 [PATCH v2] printf: convert test_hashed into macro Tamir Duberstein
2026-01-19  8:21 ` Andy Shevchenko [this message]
2026-01-20 15:50   ` Tamir Duberstein
2026-01-21 16:07     ` 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=aW3pgf4FQHFCC9Bm@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=tamird@kernel.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.