The patch titled Subject: lib/vsprintf.c: move sizeof(struct printf_spec) next to its definition has been added to the -mm tree. Its filename is lib-vsprintfc-move-sizeofstruct-printf_spec-next-to-its-definition.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/lib-vsprintfc-move-sizeofstruct-printf_spec-next-to-its-definition.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/lib-vsprintfc-move-sizeofstruct-printf_spec-next-to-its-definition.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> Subject: lib/vsprintf.c: move sizeof(struct printf_spec) next to its definition At the time of d0484193 ("lib/vsprintf.c: expand field_width to 24 bits"), there was no compiletime_assert/BUILD_BUG/.... variant that could be used outside function scope. Now we have static_assert(), so move the assertion next to the definition instead of hiding it in some arbitrary function. Also add the appropriate #include to avoid relying on build_bug.h being pulled in via some arbitrary chain of includes. Link: http://lkml.kernel.org/r/20190208203015.29702-2-linux@xxxxxxxxxxxxxxxxxx Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> Cc: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/vsprintf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/lib/vsprintf.c~lib-vsprintfc-move-sizeofstruct-printf_spec-next-to-its-definition +++ a/lib/vsprintf.c @@ -17,6 +17,7 @@ */ #include <stdarg.h> +#include <linux/build_bug.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/module.h> /* for KSYM_SYMBOL_LEN */ @@ -405,6 +406,8 @@ struct printf_spec { unsigned int base:8; /* number base, 8, 10 or 16 only */ signed int precision:16; /* # of digits/chars */ } __packed; +static_assert(sizeof(struct printf_spec) == 8); + #define FIELD_WIDTH_MAX ((1 << 23) - 1) #define PRECISION_MAX ((1 << 15) - 1) @@ -422,8 +425,6 @@ char *number(char *buf, char *end, unsig int field_width = spec.field_width; int precision = spec.precision; - BUILD_BUG_ON(sizeof(struct printf_spec) != 8); - /* locase = 0 or 0x20. ORing digits or letters with 'locase' * produces same digits or (maybe lowercased) letters */ locase = (spec.flags & SMALL); _ Patches currently in -mm which might be from linux@xxxxxxxxxxxxxxxxxx are build_bugh-add-wrapper-for-_static_assert.patch lib-vsprintfc-move-sizeofstruct-printf_spec-next-to-its-definition.patch linux-fsh-move-member-alignment-check-next-to-definition-of-struct-filename.patch