Re: [PATCH 1/3] kconfig: fix IS_ENABLED to not require all options to be defined

From: Dick Streefland
Date: Fri Apr 13 2012 - 06:32:00 EST


| +#define __ARG_PLACEHOLDER_1 0,
| +#define config_enabled(cfg) _config_enabled(cfg)
| +#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
| +#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
| +#define ___config_enabled(__ignored, val, ...) val

The ISO C99 standard requires that the variable argument macro
___config_enabled() is expanded with at least three arguments. When
a CONFIG_* macro is not defined, there are only two arguments, and
gcc will issue a somewhat cryptic warning message when you compile
with the -pedantic option:

"warning: ISO C99 requires rest arguments to be used"

Adding an additional dummy argument makes the code ISO C99 compliant,
and eliminates the warning:

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index be342b9..eac65da 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -19,7 +19,7 @@
#define __ARG_PLACEHOLDER_1 0,
#define config_enabled(cfg) _config_enabled(cfg)
#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
-#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
+#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0, 0)
#define ___config_enabled(__ignored, val, ...) val

/*

Signed-off-by: Dick Streefland <dick@xxxxxxxxxxxxxx>

--
Dick

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/