workflows.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] codingstyle: avoid unused parameters for a function-like macro
@ 2024-03-22  8:49 Barry Song
  2024-03-22  8:49 ` [PATCH v3 1/2] Documentation: coding-style: ask function-like macros to evaluate parameters Barry Song
  2024-03-22  8:49 ` [PATCH v3 2/2] scripts: checkpatch: Check unused parameters for function-like macro Barry Song
  0 siblings, 2 replies; 6+ messages in thread
From: Barry Song @ 2024-03-22  8:49 UTC (permalink / raw)
  To: corbet, workflows, linux-doc, apw, joe, dwaipayanray1, lukas.bulwahn
  Cc: linux-kernel, Barry Song

From: Barry Song <v-songbaohua@oppo.com>


A function-like macro could result in build warnings such as
"unused variable." This patchset updates the guidance to
recommend always using a static inline function instead
and also provides checkpatch support for this new rule.

Barry Song (1):
  Documentation: coding-style: ask function-like macros to evaluate
    parameters

Xining Xu (1):
  scripts: checkpatch: Check unused parameters for function-like macro

 Documentation/process/coding-style.rst | 16 ++++++++++++++++
 scripts/checkpatch.pl                  | 24 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH v3 2/2] scripts: checkpatch: check unused parameters for function-like macro
@ 2024-03-29 23:08 Charlemagne Lasse
  2024-03-30  2:49 ` Joe Perches
  0 siblings, 1 reply; 6+ messages in thread
From: Charlemagne Lasse @ 2024-03-29 23:08 UTC (permalink / raw)
  To: Barry Song, Jonathan Corbet, workflows, linux-doc,
	Andy Whitcroft, Joe Perches, Dwaipayan Ray, lukas.bulwahn
  Cc: LKML, Xining Xu, Andrew Morton

Hi,

Can this patch please be dropped from Linux-next (currently via
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm#mm-everything)?
It is obviously wrong when dealing with named variadic macro
parameters:

 ./scripts/checkpatch.pl -f include/linux/rculist.h
ERROR: Parameter 'dummy' is not used in function-like macro, please
use static inline instead
#51: FILE: include/linux/rculist.h:51:
+#define __list_check_rcu(dummy, cond, extra...)
         \
+       ({                                                              \
+       check_arg_count_one(extra);                                     \
+       RCU_LOCKDEP_WARN(!(cond) && !rcu_read_lock_any_held(),          \
+                        "RCU-list traversed in non-reader section!");  \
+       })

ERROR: Parameter 'extra...' is not used in function-like macro, please
use static inline instead
#51: FILE: include/linux/rculist.h:51:
+#define __list_check_rcu(dummy, cond, extra...)
         \
+       ({                                                              \
+       check_arg_count_one(extra);                                     \
+       RCU_LOCKDEP_WARN(!(cond) && !rcu_read_lock_any_held(),          \
+                        "RCU-list traversed in non-reader section!");  \
+       })

ERROR: Parameter 'dummy' is not used in function-like macro, please
use static inline instead
#64: FILE: include/linux/rculist.h:64:
+#define __list_check_rcu(dummy, cond, extra...)
         \
+       ({ check_arg_count_one(extra); })

ERROR: Parameter 'cond' is not used in function-like macro, please use
static inline instead
#64: FILE: include/linux/rculist.h:64:
+#define __list_check_rcu(dummy, cond, extra...)
         \
+       ({ check_arg_count_one(extra); })

ERROR: Parameter 'extra...' is not used in function-like macro, please
use static inline instead
#64: FILE: include/linux/rculist.h:64:
+#define __list_check_rcu(dummy, cond, extra...)
         \
+       ({ check_arg_count_one(extra); })

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

end of thread, other threads:[~2024-03-30  2:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22  8:49 [PATCH v3 0/2] codingstyle: avoid unused parameters for a function-like macro Barry Song
2024-03-22  8:49 ` [PATCH v3 1/2] Documentation: coding-style: ask function-like macros to evaluate parameters Barry Song
2024-03-22 14:33   ` Mark Brown
2024-03-22  8:49 ` [PATCH v3 2/2] scripts: checkpatch: Check unused parameters for function-like macro Barry Song
2024-03-29 23:08 [PATCH v3 2/2] scripts: checkpatch: check " Charlemagne Lasse
2024-03-30  2:49 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox