Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

coccinelle: Remove script that checks replacing 0/1 with false/true in functions returning bool

There is nothing wrong with current code that returns 0 or 1 for a
function returning bool. It is perfectly acceptable by the C standard.

To avoid churn of unwanted patches that are constantly sent to maintainers
who do not care about this change, remove the script that flags it as an
issue. This issue is not worth the burden on maintainers to accept
useless patches.

Link: https://lore.kernel.org/all/20220705073822.7276-1-jiapeng.chong@linux.alibaba.com/
Link: https://lore.kernel.org/all/20220429075201.68581-1-jiapeng.chong@linux.alibaba.com/
Link: https://lore.kernel.org/all/1649236467-29390-1-git-send-email-baihaowen@meizu.com/
Link: https://lore.kernel.org/all/20220317014740.3138-1-jiapeng.chong@linux.alibaba.com/
Link: https://lore.kernel.org/all/190b5c2f2f2fb9cc775fce8daed72bf893be48a4.1642065293.git.davidcomponentone@gmail.com/
Link: https://lore.kernel.org/all/20211214113845.439392-1-deng.changcheng@zte.com.cn/
Link: https://lore.kernel.org/all/20210824065735.60660-1-deng.changcheng@zte.com.cn/
Link: https://lore.kernel.org/all/20210824064305.60081-1-deng.changcheng@zte.com.cn/
Link: https://lore.kernel.org/all/20210824062359.59474-1-deng.changcheng@zte.com.cn/

Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: Paul Gortmaker <paul.gortmaker@windriver.com>

authored by

Steven Rostedt (Google) and committed by
Julia Lawall
8e54fe1b 38857318

-59
-59
scripts/coccinelle/misc/boolreturn.cocci
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /// Return statements in functions returning bool should use 3 - /// true/false instead of 1/0. 4 - // 5 - // Confidence: High 6 - // Options: --no-includes --include-headers 7 - 8 - virtual patch 9 - virtual report 10 - virtual context 11 - 12 - @r1 depends on patch@ 13 - identifier fn; 14 - typedef bool; 15 - symbol false; 16 - symbol true; 17 - @@ 18 - 19 - bool fn ( ... ) 20 - { 21 - <... 22 - return 23 - ( 24 - - 0 25 - + false 26 - | 27 - - 1 28 - + true 29 - ) 30 - ; 31 - ...> 32 - } 33 - 34 - @r2 depends on report || context@ 35 - identifier fn; 36 - position p; 37 - @@ 38 - 39 - bool fn ( ... ) 40 - { 41 - <... 42 - return 43 - ( 44 - * 0@p 45 - | 46 - * 1@p 47 - ) 48 - ; 49 - ...> 50 - } 51 - 52 - 53 - @script:python depends on report@ 54 - p << r2.p; 55 - fn << r2.fn; 56 - @@ 57 - 58 - msg = "WARNING: return of 0/1 in function '%s' with return type bool" % fn 59 - coccilib.report.print_report(p[0], msg)