archive mirror
 help / color / mirror / Atom feed
From: Lukas Bulwahn <>
To: Dwaipayan Ray <>
Subject: Re: [Linux-kernel-mentees] investigation: MULTISTATEMENT_MACRO_USE_DO_WHILE issues
Date: Mon, 28 Sep 2020 18:14:31 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.2009281805030.4154@felia> (raw)
In-Reply-To: <>

On Mon, 28 Sep 2020, Dwaipayan Ray wrote:

> Hi,
> Checkpatch seems to generate some false positives on
> certain macros.
> For example running checkpatch on (kernel/trace/trace_export.c),
> ERROR: Macros with multiple statements should be enclosed in a do - while loop
> #49: FILE: kernel/trace/trace_export.c:49:
> +#define __field_packed(type, container, item) type item;
> ERROR: Macros with multiple statements should be enclosed in a do - while loop
> #52: FILE: kernel/trace/trace_export.c:52:
> +#define __array(type, item, size) type item[size];

I guess detects the semicolon and thinks it must be two 
statements. How about checking if the semicolon is actually followed by 
anything or not?

> and several other same errors.

Are they all in one file or spread around in the kernel everywhere?
> Wrapping this in a do - while certainly doesn't make sense.
> Removing the semicolon at the end of macro and appending semicolon
> in the call changes the error to:
> ERROR: Macros with complex values should be enclosed in parentheses
> #49: FILE: kernel/trace/trace_export.c:49:
> +#define __array_desc(type, container, item, size) type item[size]
> This seems more reasonable. But the error isn't necessary in the first
> place.

Considering format or semantic checks, I would always check if 
the better check can be implemented with clang-format, clang-analyzer or 
coccinelle. is always just a quick heuristics; if other checking tools 
become part of standard check, then we could actually just refer to those 
checking tools instead.


> Thanks,
> Dwaipayan.
Linux-kernel-mentees mailing list

  reply	other threads:[~2020-09-28 16:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 15:47 [Linux-kernel-mentees] investigation: MULTISTATEMENT_MACRO_USE_DO_WHILE issues Dwaipayan Ray
2020-09-28 16:14 ` Lukas Bulwahn [this message]
2020-09-28 17:11   ` Dwaipayan Ray
2020-09-29  7:58     ` Lukas Bulwahn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.2009281805030.4154@felia \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).