lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHB1NaijJ16haCsH3uHy_zVZFXJ7_-qFOk8mFx7QSeqD+X6Z3g@mail.gmail.com>
Date: Wed, 24 Jul 2024 22:09:41 -0400
From: Julian Sun <sunjunchao2870@...il.com>
To: Joe Perches <joe@...ches.com>
Cc: linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-fsdevel@...r.kernel.org, jack@...e.cz, brauner@...nel.org, 
	viro@...iv.linux.org.uk, masahiroy@...nel.org, akpm@...ux-foundation.org, 
	n.schier@....de, ojeda@...nel.org, djwong@...nel.org, kvalo@...nel.org
Subject: Re: [PATCH] scripts: add macro_checker script to check unused
 parameters in macros

Joe Perches <joe@...ches.com> 于2024年7月24日周三 09:30写道:
>
> On Tue, 2024-07-23 at 05:11 -0400, Julian Sun wrote:
> > Hi,
> >
> > Recently, I saw a patch[1] on the ext4 mailing list regarding
> > the correction of a macro definition error. Jan mentioned
> > that "The bug in the macro is a really nasty trap...".
> > Because existing compilers are unable to detect
> > unused parameters in macro definitions. This inspired me
> > to write a script to check for unused parameters in
> > macro definitions and to run it.
> >
>
> checkpatch has a similar test:
>
> https://lkml.kernel.org/r/20240507032757.146386-3-21cnbao@gmail.com
>
> $ git log --format=email -1 b1be5844c1a0124a49a30a20a189d0a53aa10578
> From b1be5844c1a0124a49a30a20a189d0a53aa10578 Mon Sep 17 00:00:00 2001
> From: Xining Xu <mac.xxn@...look.com>
> Date: Tue, 7 May 2024 15:27:57 +1200
> Subject: [PATCH] scripts: checkpatch: check unused parameters for
>  function-like macro
>
> If function-like macros do not utilize a parameter, it might result in a
> build warning.  In our coding style guidelines, we advocate for utilizing
> static inline functions to replace such macros.  This patch verifies
> compliance with the new rule.
>
> For a macro such as the one below,
>
>  #define test(a) do { } while (0)
>
> The test result is as follows.
>
>  WARNING: Argument 'a' is not used in function-like macro
>  #21: FILE: mm/init-mm.c:20:
>  +#define test(a) do { } while (0)
>
>  total: 0 errors, 1 warnings, 8 lines checked
>
>
> > Link: https://lkml.kernel.org/r/20240507032757.146386-3-21cnbao@gmail.com
Yeah, I noticted the test. The difference between checkpatch and
macro_checker is that checkpatch only checks the patch files, instead
of the entire source files, which results in the inability to check
all macros in source files.
>

Thanks,
-- 
Julian Sun <sunjunchao2870@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ