All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx+linux-hardening@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>,
	 Chris Li <sparse@chrisli.org>,
	linux-sparse@vger.kernel.org
Cc: Alejandro Colomar <alx@kernel.org>, Kees Cook <kees@kernel.org>,
	 linux-hardening@vger.kernel.org,
	Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH v1 0/2] Simplify implementation of strscpy()
Date: Wed, 4 Nov 2026 00:21:39 +0100	[thread overview]
Message-ID: <auprDNQJl90tLBrQ@devuan> (raw)
In-Reply-To: <auoxn2Pe10D4HPKm@ashevche-desk.local>

[-- Attachment #1: Type: text/plain, Size: 1601 bytes --]

Hi Andy,

> Date: 2026-11-03 21:10:23+0200
> From: Andy Shevchenko <andriy.shevchenko@intel.com>
>
> On Tue, Nov 03, 2026 at 02:27:08PM +0100, Alejandro Colomar wrote:
> > 
> > Here's a simpler implementation of the default arguments in strscpy(9).
> > It avoids having to build concatenated names, the ignored '...' in
> > __strscpy0, counting arguments, etc.  It's replaced by a quite simple
> > macro that takes two arguments, and picks the last non-empty one.
> > 
> > It requires a C23 feature, but it's supported as a GNU extension in
> > GNU C11 mode, and was implemented a long time ago, so it should be fine.
> 
> Yes and no.
> See 551d44200152 ("default_gfp(): avoid using the "newfangled" __VA_OPT__ trick")
> for the details.

Hmmmm, so sparse is a problem.  DEFARG() cannot be implemented with
##__VA_ARGS__ (I believe), so I think this is frozen until sparse is
improved to add support for __VA_OPT__.

The implementation in that commit you pointed takes advantage of the
fact that the default value is hard-coded in the macro, and the macro
has zero fixed parameters, which makes it work, but if you add one fixed
parameter (which we need for a generic DEFARG() macro), then it doesn't
work.  GCC's ## is quite limited compared to __VA_OPT__().

I've CCed the sparse matinainer and mailing list.  Let's see if they can
add support for __VA_OPT__().

> So far NAK from me.

Makes sense.  Thanks for the review!


Have a lovely night!
Alex

> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 
> 

-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2026-11-03 23:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 13:27 [PATCH v1 0/2] Simplify implementation of strscpy() Alejandro Colomar
2026-11-03 13:27 ` [PATCH v1 1/2] args: Add DEFARG() to implement macro default arguments Alejandro Colomar
2026-11-03 13:31   ` Alejandro Colomar
2026-11-03 13:27 ` [PATCH v1 2/2] string: Simplify strscpy[_pad]() Alejandro Colomar
2026-11-03 19:10 ` [PATCH v1 0/2] Simplify implementation of strscpy() Andy Shevchenko
2026-11-03 23:21   ` Alejandro Colomar [this message]

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=auprDNQJl90tLBrQ@devuan \
    --to=alx+linux-hardening@kernel.org \
    --cc=alx@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.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.