linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Silence some instances of -Wtautological-compare and enable globally
@ 2020-02-19  4:54 Nathan Chancellor
  2020-02-19  4:54 ` [PATCH 1/6] asm/sections: Add COMPARE_SECTIONS macro Nathan Chancellor
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Nathan Chancellor @ 2020-02-19  4:54 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek, Arnd Bergmann, Steven Rostedt,
	Ingo Molnar, Jason Baron, Catalin Marinas, Andrew Morton
  Cc: linux-kernel, linux-kbuild, linux-arch, linux-mm,
	clang-built-linux, Nathan Chancellor

Hi everyone,

This patch series aims to silence some instances of clang's
-Wtautological-compare that are not problematic and enable it globally
for the kernel because it has a bunch of subwarnings that can find real
bugs in the kernel such as
https://lore.kernel.org/lkml/20200116222658.5285-1-natechancellor@gmail.com/
and https://bugs.llvm.org/show_bug.cgi?id=42666, which was specifically
requested by Dmitry.

The first patch adds a macro that casts the section variables to
unsigned long (uintptr_t), which silences the warning and adds
documentation.

Patches two through four silence the warning in the places I have
noticed it across all of my builds with -Werror, including arm, arm64,
and x86_64 defconfig/allmodconfig/allyesconfig. There might still be
more lurking but those will have to be teased out over time.

Patch six finally enables the warning, while leaving one of the
subwarnings disabled because it is rather noisy and somewhat pointless
for the kernel, where core kernel code is expected to build and run with
many different configurations where variable types can be different
sizes.

A slight meta comment: This is the first treewide patchset that I have
sent. I pray I did everything right but please let me know if I did not.
I assume someone like Andrew will pick this up with acks from everyone
but let me know if there is someone better.

Cheers,
Nathan

Nathan Chancellor (6):
  asm/sections: Add COMPARE_SECTIONS macro
  kernel/extable: Wrap section comparison in sort_main_extable with
    COMPARE_SECTIONS
  tracing: Wrap section comparison in tracer_alloc_buffers with
    COMPARE_SECTIONS
  dynamic_debug: Wrap section comparison in dynamic_debug_init with
    COMPARE_SECTIONS
  mm: kmemleak: Wrap section comparison in kmemleak_init with
    COMPARE_SECTIONS
  kbuild: Enable -Wtautological-compare

 Makefile                       | 3 +--
 include/asm-generic/sections.h | 7 +++++++
 kernel/extable.c               | 3 ++-
 kernel/trace/trace.c           | 2 +-
 lib/dynamic_debug.c            | 2 +-
 mm/kmemleak.c                  | 3 ++-
 6 files changed, 14 insertions(+), 6 deletions(-)


base-commit: 02815e777db630e3c183718cab73752b48a5053e
-- 
2.25.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-04-21  4:32 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19  4:54 [PATCH 0/6] Silence some instances of -Wtautological-compare and enable globally Nathan Chancellor
2020-02-19  4:54 ` [PATCH 1/6] asm/sections: Add COMPARE_SECTIONS macro Nathan Chancellor
2020-02-19  4:54 ` [PATCH 2/6] kernel/extable: Wrap section comparison in sort_main_extable with COMPARE_SECTIONS Nathan Chancellor
2020-02-19  4:54 ` [PATCH 3/6] tracing: Wrap section comparison in tracer_alloc_buffers " Nathan Chancellor
2020-02-19 14:34   ` Steven Rostedt
2020-02-19 17:44     ` Nick Desaulniers
2020-02-19 18:16       ` Jason Gunthorpe
2020-02-19 19:09         ` Steven Rostedt
2020-02-19 19:11         ` Nick Desaulniers
2020-02-19 19:22           ` Nathan Chancellor
2020-02-19 19:43             ` Steven Rostedt
2020-02-19 19:54           ` Jason Gunthorpe
2020-02-19 21:32             ` Nick Desaulniers
2020-02-19  4:54 ` [PATCH 4/6] dynamic_debug: Wrap section comparison in dynamic_debug_init " Nathan Chancellor
2020-02-19  4:54 ` [PATCH 5/6] mm: kmemleak: Wrap section comparison in kmemleak_init " Nathan Chancellor
2020-02-19  4:54 ` [PATCH 6/6] kbuild: Enable -Wtautological-compare Nathan Chancellor
2020-04-21  4:03 ` [PATCH 0/6] Silence some instances of -Wtautological-compare and enable globally Andrew Morton
2020-04-21  4:32   ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).