Re: Sparse not supporting kzalloc_obj() and friends
Linus Torvalds <[email protected]> Mon, 23 Feb 2026 08:35:40 -0800
| Newsgroups | org.kernel.vger.linux-sparse |
|---|---|
| Message-ID | <CAHk-=whTb01surrXakL7rgyoELuPDkqvTdh_ttNrr5rtirwopQ@mail.gmail.com> |
On Mon, 23 Feb 2026 at 08:19, Linus Torvalds <[email protected]> wrote: > > Argh. The culprit is the use of __VA_OPT__, which apparently sparse > never got taught. > [...] > Ho humm. I guess I should look at the sparse pre-processor code, > unless somebody already implemented __VA_OPT__ somewhere? Actually, it looks like Al at least *looked* at doing __VA_OPT__ back at the end of last year. In fact, just a couple of months ago I said "I'm not sure it buys us much", but that was when I thought it was just a standard versions of the gcc ## thing, and before I realized how much more convenient it actually is to use. Al? You know the pre-process.c file a *lot* better than I do, even ignoring the fact that it's been fifteen years since I touched it. And you presumably already had some thoughts on doing __VA_OPT__? That said, I can also just make default_gfp() use ## after all. I _had_ grepped for __VA_OPT__ in the kernel and decided "we already use it", but clearly it's causing some issues. So instead of <linux/gfp.h> doing #define __default_gfp(a,...) a #define default_gfp(...) __default_gfp(__VA_ARGS__ __VA_OPT__(,) GFP_KERNEL) which I think is fairly straightforward and the "natural" way to do things, the kernel can just do #define __default_gfp(a,b,...) b #define default_gfp(...) __default_gfp(,##__VA_ARGS__,GFP_KERNEL) instead, with a dummy empty argument to make the gcc ## trick work. It's smaller and denser, so it's actually superior in that sense, even if it feels a bit less natural than the __VA_OPT__ model. Ricardo, can you verify that that trick works for you? Al, comments? Linus