Skip to content

Commit 551d442

Browse files
committed
default_gfp(): avoid using the "newfangled" __VA_OPT__ trick
The default_gfp() helper that I added is not wrong, but it turns out that it causes unnecessary headaches for 'sparse' which doesn't support the use of __VA_OPT__ (introduced in C++20 and C23, and supported by gcc and clang for a long time). We do already use __VA_OPT__ in some other cases in the kernel (drm/xe and btrfs), but it has been fairly limited. Now it triggers for pretty much everything, and sparse ends up not working at all. We can use the traditional gcc ',##__VA_ARGS__' syntax instead: it may not be the "C standard" way and is slightly less natural in this context, but it is the traditional model for this and avoids the sparse problem. Reported-and-tested-by: Ricardo Ribalda <ribalda@chromium.org> Reported-and-tested-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reported-by: Ben Dooks <ben.dooks@codethink.co.uk> Fixes: e19e1b4 ("add default_gfp() helper macro and use it in the new *alloc_obj() helpers") Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6de23f8 commit 551d442

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

include/linux/gfp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ struct vm_area_struct;
1414
struct mempolicy;
1515

1616
/* Helper macro to avoid gfp flags if they are the default one */
17-
#define __default_gfp(a,...) a
18-
#define default_gfp(...) __default_gfp(__VA_ARGS__ __VA_OPT__(,) GFP_KERNEL)
17+
#define __default_gfp(a,b,...) b
18+
#define default_gfp(...) __default_gfp(,##__VA_ARGS__,GFP_KERNEL)
1919

2020
/* Convert GFP flags to their corresponding migrate type */
2121
#define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE)

0 commit comments

Comments
 (0)