All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: Enable -Wtautological-compare
@ 2020-03-26 19:41 Nathan Chancellor
  2020-03-27  5:07 ` kbuild test robot
  2020-03-29 11:31 ` Masahiro Yamada
  0 siblings, 2 replies; 7+ messages in thread
From: Nathan Chancellor @ 2020-03-26 19:41 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek
  Cc: linux-kbuild, linux-kernel, clang-built-linux, Nick Desaulniers,
	Dmitry Vyukov, Gustavo A. R. Silva, Nathan Chancellor

Currently, we disable -Wtautological-compare, which in turn disables a
bunch of more specific tautological comparison warnings that are useful
for the kernel such as -Wtautological-bitwise-compare. See clang's
documentation below for the other warnings that are suppressed by
-Wtautological-compare. Now that all of the major/noisy warnings have
been fixed, enable -Wtautological-compare so that more issues can be
caught at build time by various continuous integration setups.

-Wtautological-constant-out-of-range-compare is kept disabled under a
normal build but visible at W=1 because there are places in the kernel
where a constant or variable size can change based on the kernel
configuration. These are not fixed in a clean/concise way and the ones
I have audited so far appear to be harmless. It is not a subgroup but
rather just one warning so we do not lose out on much coverage by
default.

Link: https://github.com/ClangBuiltLinux/linux/issues/488
Link: http://releases.llvm.org/10.0.0/tools/clang/docs/DiagnosticsReference.html#wtautological-compare
Link: https://bugs.llvm.org/show_bug.cgi?id=42666
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---

v1 -> v2: https://lore.kernel.org/lkml/20200219045423.54190-7-natechancellor@gmail.com/

* Expand commit message a bit by adding more reasoning behind change.
* Disable -Wtautological-constant-out-of-range-compare under a normal
  build but allow it to show up at W=1 for easy auditing.

I hope this can be accepted for 5.7. There are two warnings that I see
still across a bunch of allyesconfig/allmodconfig builds that have
patches sent but not accepted. I will ping them today.

* https://lore.kernel.org/lkml/20191023002014.22571-1-natechancellor@gmail.com/
* https://lore.kernel.org/lkml/20200220051011.26113-1-natechancellor@gmail.com/

 Makefile                   | 2 --
 scripts/Makefile.extrawarn | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index db442a9ee6b2..05f9f50dda3e 100644
--- a/Makefile
+++ b/Makefile
@@ -746,8 +746,6 @@ ifdef CONFIG_CC_IS_CLANG
 KBUILD_CPPFLAGS += -Qunused-arguments
 KBUILD_CFLAGS += -Wno-format-invalid-specifier
 KBUILD_CFLAGS += -Wno-gnu
-# Quiet clang warning: comparison of unsigned expression < 0 is always false
-KBUILD_CFLAGS += -Wno-tautological-compare
 # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
 # source of a reference will be _MergedGlobals and not on of the whitelisted names.
 # See modpost pattern 2
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index ca08f2fe7c34..4aea7cf71d11 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -49,6 +49,7 @@ KBUILD_CFLAGS += -Wno-format
 KBUILD_CFLAGS += -Wno-sign-compare
 KBUILD_CFLAGS += -Wno-format-zero-length
 KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
+KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
 endif
 
 endif
-- 
2.26.0


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

* Re: [PATCH v2] kbuild: Enable -Wtautological-compare
  2020-03-26 19:41 [PATCH v2] kbuild: Enable -Wtautological-compare Nathan Chancellor
@ 2020-03-27  5:07 ` kbuild test robot
  2020-03-29 11:31 ` Masahiro Yamada
  1 sibling, 0 replies; 7+ messages in thread
From: kbuild test robot @ 2020-03-27  5:07 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 13217 bytes --]

Hi Nathan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kbuild/for-next]
[also build test WARNING on v5.6-rc7 next-20200326]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Nathan-Chancellor/kbuild-Enable-Wtautological-compare/20200327-072823
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
config: x86_64-defconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 2a43a1610db335afcccd1a179a33a0886a5a2c4d)
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> kernel//trace/trace.c:9337:33: warning: array comparison always evaluates to true [-Wtautological-compare]
           if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt)
                                          ^
   1 warning generated.

vim +9337 kernel//trace/trace.c

7e465baa80293e Tom Zanussi               2017-09-22  9312  
3928a8a2d98081 Steven Rostedt            2008-09-29  9313  __init static int tracer_alloc_buffers(void)
bc0c38d139ec7f Steven Rostedt            2008-05-12  9314  {
73c5162aa362a5 Steven Rostedt            2009-03-11  9315  	int ring_buf_size;
9e01c1b74c9531 Rusty Russell             2009-01-01  9316  	int ret = -ENOMEM;
4c11d7aed38937 Steven Rostedt            2008-05-12  9317  
a356646a56857c Steven Rostedt (VMware    2019-12-02  9318) 
a356646a56857c Steven Rostedt (VMware    2019-12-02  9319) 	if (security_locked_down(LOCKDOWN_TRACEFS)) {
ee19545220a866 Stephen Rothwell          2019-12-06  9320  		pr_warn("Tracing disabled due to lockdown\n");
a356646a56857c Steven Rostedt (VMware    2019-12-02  9321) 		return -EPERM;
a356646a56857c Steven Rostedt (VMware    2019-12-02  9322) 	}
a356646a56857c Steven Rostedt (VMware    2019-12-02  9323) 
b5e87c05813194 Steven Rostedt (Red Hat   2015-09-29  9324) 	/*
b5e87c05813194 Steven Rostedt (Red Hat   2015-09-29  9325) 	 * Make sure we don't accidently add more trace options
b5e87c05813194 Steven Rostedt (Red Hat   2015-09-29  9326) 	 * than we have bits for.
b5e87c05813194 Steven Rostedt (Red Hat   2015-09-29  9327) 	 */
9a38a8856f41f9 Steven Rostedt (Red Hat   2015-09-30  9328) 	BUILD_BUG_ON(TRACE_ITER_LAST_BIT > TRACE_FLAGS_MAX_SIZE);
b5e87c05813194 Steven Rostedt (Red Hat   2015-09-29  9329) 
9e01c1b74c9531 Rusty Russell             2009-01-01  9330  	if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
9e01c1b74c9531 Rusty Russell             2009-01-01  9331  		goto out;
9e01c1b74c9531 Rusty Russell             2009-01-01  9332  
ccfe9e42e45123 Alexander Z Lam           2013-08-08  9333  	if (!alloc_cpumask_var(&global_trace.tracing_cpumask, GFP_KERNEL))
9e01c1b74c9531 Rusty Russell             2009-01-01  9334  		goto out_free_buffer_mask;
a98a3c3fde3ae7 Steven Rostedt            2008-05-12  9335  
07d777fe8c3985 Steven Rostedt            2011-09-22  9336  	/* Only allocate trace_printk buffers if a trace_printk exists */
07d777fe8c3985 Steven Rostedt            2011-09-22 @9337  	if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt)
81698831bc462f Steven Rostedt            2012-10-11  9338  		/* Must be called before global_trace.buffer is allocated */
07d777fe8c3985 Steven Rostedt            2011-09-22  9339  		trace_printk_init_buffers();
07d777fe8c3985 Steven Rostedt            2011-09-22  9340  
73c5162aa362a5 Steven Rostedt            2009-03-11  9341  	/* To save memory, keep the ring buffer size to its minimum */
73c5162aa362a5 Steven Rostedt            2009-03-11  9342  	if (ring_buffer_expanded)
73c5162aa362a5 Steven Rostedt            2009-03-11  9343  		ring_buf_size = trace_buf_size;
73c5162aa362a5 Steven Rostedt            2009-03-11  9344  	else
73c5162aa362a5 Steven Rostedt            2009-03-11  9345  		ring_buf_size = 1;
73c5162aa362a5 Steven Rostedt            2009-03-11  9346  
9e01c1b74c9531 Rusty Russell             2009-01-01  9347  	cpumask_copy(tracing_buffer_mask, cpu_possible_mask);
ccfe9e42e45123 Alexander Z Lam           2013-08-08  9348  	cpumask_copy(global_trace.tracing_cpumask, cpu_all_mask);
9e01c1b74c9531 Rusty Russell             2009-01-01  9349  
2b6080f28c7cc3 Steven Rostedt            2012-05-11  9350  	raw_spin_lock_init(&global_trace.start_lock);
2b6080f28c7cc3 Steven Rostedt            2012-05-11  9351  
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9352  	/*
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9353  	 * The prepare callbacks allocates some memory for the ring buffer. We
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9354  	 * don't free the buffer if the if the CPU goes down. If we were to free
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9355  	 * the buffer, then the user would lose any trace that was in the
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9356  	 * buffer. The memory will be removed once the "instance" is removed.
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9357  	 */
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9358  	ret = cpuhp_setup_state_multi(CPUHP_TRACE_RB_PREPARE,
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9359  				      "trace/RB:preapre", trace_rb_cpu_prepare,
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9360  				      NULL);
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9361  	if (ret < 0)
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9362  		goto out_free_cpumask;
2c4a33aba5f9ea Steven Rostedt (Red Hat   2014-03-25  9363) 	/* Used for event triggers */
147d88e0b5eb90 Dan Carpenter             2017-08-01  9364  	ret = -ENOMEM;
2c4a33aba5f9ea Steven Rostedt (Red Hat   2014-03-25  9365) 	temp_buffer = ring_buffer_alloc(PAGE_SIZE, RB_FL_OVERWRITE);
2c4a33aba5f9ea Steven Rostedt (Red Hat   2014-03-25  9366) 	if (!temp_buffer)
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9367  		goto out_rm_hp_state;
2c4a33aba5f9ea Steven Rostedt (Red Hat   2014-03-25  9368) 
939c7a4f04fcd2 Yoshihiro YUNOMAE         2014-06-05  9369  	if (trace_create_savedcmd() < 0)
939c7a4f04fcd2 Yoshihiro YUNOMAE         2014-06-05  9370  		goto out_free_temp_buffer;
939c7a4f04fcd2 Yoshihiro YUNOMAE         2014-06-05  9371  
9e01c1b74c9531 Rusty Russell             2009-01-01  9372  	/* TODO: make the number of buffers hot pluggable with CPUS */
737223fbca3b1c Steven Rostedt (Red Hat   2013-03-05  9373) 	if (allocate_trace_buffers(&global_trace, ring_buf_size) < 0) {
24589e3a20876d Steven Rostedt (VMware    2020-01-25  9374) 		MEM_FAIL(1, "tracer: failed to allocate ring buffer!\n");
939c7a4f04fcd2 Yoshihiro YUNOMAE         2014-06-05  9375  		goto out_free_savedcmd;
a98a3c3fde3ae7 Steven Rostedt            2008-05-12  9376  	}
a7603ff4b5f7e2 Steven Rostedt            2012-08-06  9377  
499e547057f5bb Steven Rostedt            2012-02-22  9378  	if (global_trace.buffer_disabled)
499e547057f5bb Steven Rostedt            2012-02-22  9379  		tracing_off();
a98a3c3fde3ae7 Steven Rostedt            2008-05-12  9380  
e1e232ca6b8faa Steven Rostedt            2014-02-10  9381  	if (trace_boot_clock) {
e1e232ca6b8faa Steven Rostedt            2014-02-10  9382  		ret = tracing_set_clock(&global_trace, trace_boot_clock);
e1e232ca6b8faa Steven Rostedt            2014-02-10  9383  		if (ret < 0)
a395d6a7e3d6e3 Joe Perches               2016-03-22  9384  			pr_warn("Trace clock %s not defined, going back to default\n",
e1e232ca6b8faa Steven Rostedt            2014-02-10  9385  				trace_boot_clock);
e1e232ca6b8faa Steven Rostedt            2014-02-10  9386  	}
e1e232ca6b8faa Steven Rostedt            2014-02-10  9387  
ca1643186d3dce Steven Rostedt (Red Hat   2013-05-23  9388) 	/*
ca1643186d3dce Steven Rostedt (Red Hat   2013-05-23  9389) 	 * register_tracer() might reference current_trace, so it
ca1643186d3dce Steven Rostedt (Red Hat   2013-05-23  9390) 	 * needs to be set before we register anything. This is
ca1643186d3dce Steven Rostedt (Red Hat   2013-05-23  9391) 	 * just a bootstrap of current_trace anyway.
ca1643186d3dce Steven Rostedt (Red Hat   2013-05-23  9392) 	 */
2b6080f28c7cc3 Steven Rostedt            2012-05-11  9393  	global_trace.current_trace = &nop_trace;
2b6080f28c7cc3 Steven Rostedt            2012-05-11  9394  
0b9b12c1b884eb Steven Rostedt (Red Hat   2014-01-14  9395) 	global_trace.max_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
0b9b12c1b884eb Steven Rostedt (Red Hat   2014-01-14  9396) 
4104d326b670c2 Steven Rostedt (Red Hat   2014-01-10  9397) 	ftrace_init_global_array_ops(&global_trace);
4104d326b670c2 Steven Rostedt (Red Hat   2014-01-10  9398) 
9a38a8856f41f9 Steven Rostedt (Red Hat   2015-09-30  9399) 	init_trace_flags_index(&global_trace);
9a38a8856f41f9 Steven Rostedt (Red Hat   2015-09-30  9400) 
ca1643186d3dce Steven Rostedt (Red Hat   2013-05-23  9401) 	register_tracer(&nop_trace);
ca1643186d3dce Steven Rostedt (Red Hat   2013-05-23  9402) 
dbeafd0d6131d0 Steven Rostedt (VMware    2017-03-03  9403) 	/* Function tracing may start here (via kernel command line) */
dbeafd0d6131d0 Steven Rostedt (VMware    2017-03-03  9404) 	init_function_trace();
dbeafd0d6131d0 Steven Rostedt (VMware    2017-03-03  9405) 
60a11774b38fef Steven Rostedt            2008-05-12  9406  	/* All seems OK, enable tracing */
60a11774b38fef Steven Rostedt            2008-05-12  9407  	tracing_disabled = 0;
3928a8a2d98081 Steven Rostedt            2008-09-29  9408  
3f5a54e371ca20 Steven Rostedt            2008-07-30  9409  	atomic_notifier_chain_register(&panic_notifier_list,
3f5a54e371ca20 Steven Rostedt            2008-07-30  9410  				       &trace_panic_notifier);
3f5a54e371ca20 Steven Rostedt            2008-07-30  9411  
3f5a54e371ca20 Steven Rostedt            2008-07-30  9412  	register_die_notifier(&trace_die_notifier);
2fc1dfbe17e770 Frederic Weisbecker       2009-03-16  9413  
ae63b31e4d0e2e Steven Rostedt            2012-05-03  9414  	global_trace.flags = TRACE_ARRAY_FL_GLOBAL;
ae63b31e4d0e2e Steven Rostedt            2012-05-03  9415  
ae63b31e4d0e2e Steven Rostedt            2012-05-03  9416  	INIT_LIST_HEAD(&global_trace.systems);
ae63b31e4d0e2e Steven Rostedt            2012-05-03  9417  	INIT_LIST_HEAD(&global_trace.events);
067fe038e70f6e Tom Zanussi               2018-01-15  9418  	INIT_LIST_HEAD(&global_trace.hist_vars);
2f754e771b1a6f Steven Rostedt (VMware    2019-04-01  9419) 	INIT_LIST_HEAD(&global_trace.err_log);
ae63b31e4d0e2e Steven Rostedt            2012-05-03  9420  	list_add(&global_trace.list, &ftrace_trace_arrays);
ae63b31e4d0e2e Steven Rostedt            2012-05-03  9421  
a4d1e688230339 Jiaxing Wang              2015-11-04  9422  	apply_trace_boot_options();
7bcfaf54f591a0 Steven Rostedt            2012-11-01  9423  
77fd5c15e3216b Steven Rostedt (Red Hat   2013-03-12  9424) 	register_snapshot_cmd();
77fd5c15e3216b Steven Rostedt (Red Hat   2013-03-12  9425) 
2fc1dfbe17e770 Frederic Weisbecker       2009-03-16  9426  	return 0;
3f5a54e371ca20 Steven Rostedt            2008-07-30  9427  
939c7a4f04fcd2 Yoshihiro YUNOMAE         2014-06-05  9428  out_free_savedcmd:
939c7a4f04fcd2 Yoshihiro YUNOMAE         2014-06-05  9429  	free_saved_cmdlines_buffer(savedcmd);
2c4a33aba5f9ea Steven Rostedt (Red Hat   2014-03-25  9430) out_free_temp_buffer:
2c4a33aba5f9ea Steven Rostedt (Red Hat   2014-03-25  9431) 	ring_buffer_free(temp_buffer);
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9432  out_rm_hp_state:
b32614c03413f8 Sebastian Andrzej Siewior 2016-11-27  9433  	cpuhp_remove_multi_state(CPUHP_TRACE_RB_PREPARE);
9e01c1b74c9531 Rusty Russell             2009-01-01  9434  out_free_cpumask:
ccfe9e42e45123 Alexander Z Lam           2013-08-08  9435  	free_cpumask_var(global_trace.tracing_cpumask);
9e01c1b74c9531 Rusty Russell             2009-01-01  9436  out_free_buffer_mask:
9e01c1b74c9531 Rusty Russell             2009-01-01  9437  	free_cpumask_var(tracing_buffer_mask);
9e01c1b74c9531 Rusty Russell             2009-01-01  9438  out:
9e01c1b74c9531 Rusty Russell             2009-01-01  9439  	return ret;
bc0c38d139ec7f Steven Rostedt            2008-05-12  9440  }
b2821ae68b1448 Steven Rostedt            2009-02-02  9441  

:::::: The code@line 9337 was first introduced by commit
:::::: 07d777fe8c3985bc83428c2866713c2d1b3d4129 tracing: Add percpu buffers for trace_printk()

:::::: TO: Steven Rostedt <srostedt@redhat.com>
:::::: CC: Steven Rostedt <rostedt@goodmis.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29184 bytes --]

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

* Re: [PATCH v2] kbuild: Enable -Wtautological-compare
  2020-03-26 19:41 [PATCH v2] kbuild: Enable -Wtautological-compare Nathan Chancellor
  2020-03-27  5:07 ` kbuild test robot
@ 2020-03-29 11:31 ` Masahiro Yamada
  2020-03-31 10:11   ` Nathan Chancellor
  1 sibling, 1 reply; 7+ messages in thread
From: Masahiro Yamada @ 2020-03-29 11:31 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, clang-built-linux, Nick Desaulniers,
	Dmitry Vyukov, Gustavo A. R. Silva

On Fri, Mar 27, 2020 at 4:42 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Currently, we disable -Wtautological-compare, which in turn disables a
> bunch of more specific tautological comparison warnings that are useful
> for the kernel such as -Wtautological-bitwise-compare. See clang's
> documentation below for the other warnings that are suppressed by
> -Wtautological-compare. Now that all of the major/noisy warnings have
> been fixed, enable -Wtautological-compare so that more issues can be
> caught at build time by various continuous integration setups.
>
> -Wtautological-constant-out-of-range-compare is kept disabled under a
> normal build but visible at W=1 because there are places in the kernel
> where a constant or variable size can change based on the kernel
> configuration. These are not fixed in a clean/concise way and the ones
> I have audited so far appear to be harmless. It is not a subgroup but
> rather just one warning so we do not lose out on much coverage by
> default.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/488
> Link: http://releases.llvm.org/10.0.0/tools/clang/docs/DiagnosticsReference.html#wtautological-compare
> Link: https://bugs.llvm.org/show_bug.cgi?id=42666
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>
> v1 -> v2: https://lore.kernel.org/lkml/20200219045423.54190-7-natechancellor@gmail.com/
>
> * Expand commit message a bit by adding more reasoning behind change.
> * Disable -Wtautological-constant-out-of-range-compare under a normal
>   build but allow it to show up at W=1 for easy auditing.
>
> I hope this can be accepted for 5.7. There are two warnings that I see
> still across a bunch of allyesconfig/allmodconfig builds that have
> patches sent but not accepted. I will ping them today.
>
> * https://lore.kernel.org/lkml/20191023002014.22571-1-natechancellor@gmail.com/
> * https://lore.kernel.org/lkml/20200220051011.26113-1-natechancellor@gmail.com/


OK, I will queue this up and send it to Linus
in the second week of MW.

I hope all warnings will be fixed by that time.



-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH v2] kbuild: Enable -Wtautological-compare
  2020-03-29 11:31 ` Masahiro Yamada
@ 2020-03-31 10:11   ` Nathan Chancellor
  2020-03-31 16:02     ` Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2020-03-31 10:11 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, clang-built-linux, Nick Desaulniers,
	Dmitry Vyukov, Gustavo A. R. Silva

On Sun, Mar 29, 2020 at 08:31:26PM +0900, Masahiro Yamada wrote:
> On Fri, Mar 27, 2020 at 4:42 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Currently, we disable -Wtautological-compare, which in turn disables a
> > bunch of more specific tautological comparison warnings that are useful
> > for the kernel such as -Wtautological-bitwise-compare. See clang's
> > documentation below for the other warnings that are suppressed by
> > -Wtautological-compare. Now that all of the major/noisy warnings have
> > been fixed, enable -Wtautological-compare so that more issues can be
> > caught at build time by various continuous integration setups.
> >
> > -Wtautological-constant-out-of-range-compare is kept disabled under a
> > normal build but visible at W=1 because there are places in the kernel
> > where a constant or variable size can change based on the kernel
> > configuration. These are not fixed in a clean/concise way and the ones
> > I have audited so far appear to be harmless. It is not a subgroup but
> > rather just one warning so we do not lose out on much coverage by
> > default.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/488
> > Link: http://releases.llvm.org/10.0.0/tools/clang/docs/DiagnosticsReference.html#wtautological-compare
> > Link: https://bugs.llvm.org/show_bug.cgi?id=42666
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >
> > v1 -> v2: https://lore.kernel.org/lkml/20200219045423.54190-7-natechancellor@gmail.com/
> >
> > * Expand commit message a bit by adding more reasoning behind change.
> > * Disable -Wtautological-constant-out-of-range-compare under a normal
> >   build but allow it to show up at W=1 for easy auditing.
> >
> > I hope this can be accepted for 5.7. There are two warnings that I see
> > still across a bunch of allyesconfig/allmodconfig builds that have
> > patches sent but not accepted. I will ping them today.
> >
> > * https://lore.kernel.org/lkml/20191023002014.22571-1-natechancellor@gmail.com/
> > * https://lore.kernel.org/lkml/20200220051011.26113-1-natechancellor@gmail.com/
> 
> 
> OK, I will queue this up and send it to Linus
> in the second week of MW.
> 
> I hope all warnings will be fixed by that time.

Just a follow up, those two patches have been picked up and should be in
this coming release:

https://git.kernel.org/balbi/usb/c/58582220d2d34228e5a1e1585e41b735713988bb
https://git.kernel.org/rostedt/linux-trace/c/bf2cbe044da275021b2de5917240411a19e5c50d

As of next-20200331, with the former applied (because it is not there
yet) along with this patch, I see no warnings on arm, arm64, x86_64
all{mod,yes}config.

Cheers,
Nathan

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

* Re: [PATCH v2] kbuild: Enable -Wtautological-compare
  2020-03-31 10:11   ` Nathan Chancellor
@ 2020-03-31 16:02     ` Nick Desaulniers
  2020-03-31 19:26       ` Nathan Chancellor
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2020-03-31 16:02 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Masahiro Yamada, Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, clang-built-linux, Dmitry Vyukov,
	Gustavo A. R. Silva

On Tue, Mar 31, 2020 at 3:11 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
> Just a follow up, those two patches have been picked up and should be in
> this coming release:
>
> https://git.kernel.org/balbi/usb/c/58582220d2d34228e5a1e1585e41b735713988bb
> https://git.kernel.org/rostedt/linux-trace/c/bf2cbe044da275021b2de5917240411a19e5c50d
>
> As of next-20200331, with the former applied (because it is not there
> yet) along with this patch, I see no warnings on arm, arm64, x86_64
> all{mod,yes}config.

kbuild test robot is testing more arch's than that with Clang so it
may report if it finds more instances of that warning in those.

-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH v2] kbuild: Enable -Wtautological-compare
  2020-03-31 16:02     ` Nick Desaulniers
@ 2020-03-31 19:26       ` Nathan Chancellor
  2020-04-02 17:05         ` Masahiro Yamada
  0 siblings, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2020-03-31 19:26 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Masahiro Yamada, Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, clang-built-linux, Dmitry Vyukov,
	Gustavo A. R. Silva

On Tue, Mar 31, 2020 at 09:02:19AM -0700, 'Nick Desaulniers' via Clang Built Linux wrote:
> On Tue, Mar 31, 2020 at 3:11 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> > Just a follow up, those two patches have been picked up and should be in
> > this coming release:
> >
> > https://git.kernel.org/balbi/usb/c/58582220d2d34228e5a1e1585e41b735713988bb
> > https://git.kernel.org/rostedt/linux-trace/c/bf2cbe044da275021b2de5917240411a19e5c50d
> >
> > As of next-20200331, with the former applied (because it is not there
> > yet) along with this patch, I see no warnings on arm, arm64, x86_64
> > all{mod,yes}config.
> 
> kbuild test robot is testing more arch's than that with Clang so it
> may report if it finds more instances of that warning in those.
> 
> -- 
> Thanks,
> ~Nick Desaulniers
> 

I'll keep an eye out. Hopefully not too many more are lurking but we
have definitely caught some bad behavior with this warning already so
getting it turned on so that all CI systems can benefit from it is
important.

Cheers,
Nathan

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

* Re: [PATCH v2] kbuild: Enable -Wtautological-compare
  2020-03-31 19:26       ` Nathan Chancellor
@ 2020-04-02 17:05         ` Masahiro Yamada
  0 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2020-04-02 17:05 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nick Desaulniers, Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, clang-built-linux, Dmitry Vyukov,
	Gustavo A. R. Silva

On Wed, Apr 1, 2020 at 4:26 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Tue, Mar 31, 2020 at 09:02:19AM -0700, 'Nick Desaulniers' via Clang Built Linux wrote:
> > On Tue, Mar 31, 2020 at 3:11 AM Nathan Chancellor
> > <natechancellor@gmail.com> wrote:
> > > Just a follow up, those two patches have been picked up and should be in
> > > this coming release:
> > >
> > > https://git.kernel.org/balbi/usb/c/58582220d2d34228e5a1e1585e41b735713988bb
> > > https://git.kernel.org/rostedt/linux-trace/c/bf2cbe044da275021b2de5917240411a19e5c50d
> > >
> > > As of next-20200331, with the former applied (because it is not there
> > > yet) along with this patch, I see no warnings on arm, arm64, x86_64
> > > all{mod,yes}config.
> >
> > kbuild test robot is testing more arch's than that with Clang so it
> > may report if it finds more instances of that warning in those.
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
> >
>
> I'll keep an eye out. Hopefully not too many more are lurking but we
> have definitely caught some bad behavior with this warning already so
> getting it turned on so that all CI systems can benefit from it is
> important.
>
> Cheers,
> Nathan



Applied to linux-kbuild.

I will rebase my branch during this MW,
so the commit ID will be unstable.
Please do not record it until it lands in Linus' tree.

-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2020-04-02 17:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 19:41 [PATCH v2] kbuild: Enable -Wtautological-compare Nathan Chancellor
2020-03-27  5:07 ` kbuild test robot
2020-03-29 11:31 ` Masahiro Yamada
2020-03-31 10:11   ` Nathan Chancellor
2020-03-31 16:02     ` Nick Desaulniers
2020-03-31 19:26       ` Nathan Chancellor
2020-04-02 17:05         ` Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.