Bug 1369622 - Add a static_assert when no variadic argument is given to MOZ_CRASH_UNSAFE_PRINTF. r=froydnj

If MOZ_CRASH_UNSAFE_PRINTF is only given a format string, it means
either arguments are missing, or MOZ_CRASH should be used instead.
Hint at that with a static_assert.

--HG--
extra : rebase_source : 355c37deb8b007e61939a4c657e411d110e7bbe7
This commit is contained in:
Mike Hommey 2017-06-02 15:11:47 +09:00
parent e9c25fa403
commit 05a36a133a

View File

@ -314,6 +314,10 @@ MOZ_CrashPrintf(const char* aFilename, int aLine, const char* aFormat, ...);
*/
#define MOZ_CRASH_UNSAFE_PRINTF(format, ...) \
do { \
static_assert( \
MOZ_ARG_COUNT(__VA_ARGS__) > 0, \
"Did you forget arguments to MOZ_CRASH_UNSAFE_PRINTF? " \
"Or maybe you want MOZ_CRASH instead?"); \
static_assert( \
MOZ_ARG_COUNT(__VA_ARGS__) <= sPrintfMaxArgs, \
"Only up to 4 additional arguments are allowed!"); \