diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/Makefile | 2 | ||||
-rw-r--r-- | include/linux/compiler.h | 17 | ||||
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | scripts/Makefile.extrawarn | 1 |
5 files changed, 7 insertions, 18 deletions
@@ -801,6 +801,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) | |||
801 | # warn about C99 declaration after statement | 801 | # warn about C99 declaration after statement |
802 | KBUILD_CFLAGS += -Wdeclaration-after-statement | 802 | KBUILD_CFLAGS += -Wdeclaration-after-statement |
803 | 803 | ||
804 | # Variable Length Arrays (VLAs) should not be used anywhere in the kernel | ||
805 | KBUILD_CFLAGS += $(call cc-option,-Wvla) | ||
806 | |||
804 | # disable pointer signed / unsigned warnings in gcc 4.0 | 807 | # disable pointer signed / unsigned warnings in gcc 4.0 |
805 | KBUILD_CFLAGS += -Wno-pointer-sign | 808 | KBUILD_CFLAGS += -Wno-pointer-sign |
806 | 809 | ||
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 5794f102f9b8..1c2857f13ad4 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile | |||
@@ -12,7 +12,7 @@ | |||
12 | # Note the danger in using -Wall -Wextra is that when CI updates gcc we | 12 | # Note the danger in using -Wall -Wextra is that when CI updates gcc we |
13 | # will most likely get a sudden build breakage... Hopefully we will fix | 13 | # will most likely get a sudden build breakage... Hopefully we will fix |
14 | # new warnings before CI updates! | 14 | # new warnings before CI updates! |
15 | subdir-ccflags-y := -Wall -Wextra -Wvla | 15 | subdir-ccflags-y := -Wall -Wextra |
16 | subdir-ccflags-y += $(call cc-disable-warning, unused-parameter) | 16 | subdir-ccflags-y += $(call cc-disable-warning, unused-parameter) |
17 | subdir-ccflags-y += $(call cc-disable-warning, type-limits) | 17 | subdir-ccflags-y += $(call cc-disable-warning, type-limits) |
18 | subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers) | 18 | subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers) |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 1921545c6351..4170fcee5adb 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -344,29 +344,14 @@ static inline void *offset_to_ptr(const int *off) | |||
344 | #endif | 344 | #endif |
345 | #ifndef __compiletime_error | 345 | #ifndef __compiletime_error |
346 | # define __compiletime_error(message) | 346 | # define __compiletime_error(message) |
347 | /* | ||
348 | * Sparse complains of variable sized arrays due to the temporary variable in | ||
349 | * __compiletime_assert. Unfortunately we can't just expand it out to make | ||
350 | * sparse see a constant array size without breaking compiletime_assert on old | ||
351 | * versions of GCC (e.g. 4.2.4), so hide the array from sparse altogether. | ||
352 | */ | ||
353 | # ifndef __CHECKER__ | ||
354 | # define __compiletime_error_fallback(condition) \ | ||
355 | do { ((void)sizeof(char[1 - 2 * condition])); } while (0) | ||
356 | # endif | ||
357 | #endif | ||
358 | #ifndef __compiletime_error_fallback | ||
359 | # define __compiletime_error_fallback(condition) do { } while (0) | ||
360 | #endif | 347 | #endif |
361 | 348 | ||
362 | #ifdef __OPTIMIZE__ | 349 | #ifdef __OPTIMIZE__ |
363 | # define __compiletime_assert(condition, msg, prefix, suffix) \ | 350 | # define __compiletime_assert(condition, msg, prefix, suffix) \ |
364 | do { \ | 351 | do { \ |
365 | int __cond = !(condition); \ | ||
366 | extern void prefix ## suffix(void) __compiletime_error(msg); \ | 352 | extern void prefix ## suffix(void) __compiletime_error(msg); \ |
367 | if (__cond) \ | 353 | if (!(condition)) \ |
368 | prefix ## suffix(); \ | 354 | prefix ## suffix(); \ |
369 | __compiletime_error_fallback(__cond); \ | ||
370 | } while (0) | 355 | } while (0) |
371 | #else | 356 | #else |
372 | # define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0) | 357 | # define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0) |
diff --git a/lib/Makefile b/lib/Makefile index 3d341f59f756..988949c4fd3a 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -53,7 +53,9 @@ obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o | |||
53 | obj-$(CONFIG_TEST_IDA) += test_ida.o | 53 | obj-$(CONFIG_TEST_IDA) += test_ida.o |
54 | obj-$(CONFIG_TEST_KASAN) += test_kasan.o | 54 | obj-$(CONFIG_TEST_KASAN) += test_kasan.o |
55 | CFLAGS_test_kasan.o += -fno-builtin | 55 | CFLAGS_test_kasan.o += -fno-builtin |
56 | CFLAGS_test_kasan.o += $(call cc-disable-warning, vla) | ||
56 | obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o | 57 | obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o |
58 | CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla) | ||
57 | UBSAN_SANITIZE_test_ubsan.o := y | 59 | UBSAN_SANITIZE_test_ubsan.o := y |
58 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o | 60 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o |
59 | obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o | 61 | obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o |
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 8d5357053f86..24b2fb1d1297 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn | |||
@@ -52,7 +52,6 @@ warning-3 += -Wpointer-arith | |||
52 | warning-3 += -Wredundant-decls | 52 | warning-3 += -Wredundant-decls |
53 | warning-3 += -Wswitch-default | 53 | warning-3 += -Wswitch-default |
54 | warning-3 += $(call cc-option, -Wpacked-bitfield-compat) | 54 | warning-3 += $(call cc-option, -Wpacked-bitfield-compat) |
55 | warning-3 += $(call cc-option, -Wvla) | ||
56 | 55 | ||
57 | warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | 56 | warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) |
58 | warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | 57 | warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) |