[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] checkpatch: warn when using volatile with a com
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] checkpatch: warn when using volatile with a comment |
Date: |
Mon, 18 Dec 2017 13:49:52 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 |
On 15/12/2017 19:18, Marc-André Lureau wrote:
> Instead of an error, lower to a warning message, assuming the comment
> gives some justification.
>
> Discussed in:
> '[Qemu-devel] [PATCH] dump-guest-memory.py: fix "You can't do that without a
> process to debug"'
>
> Suggested-by: Fam Zheng <address@hidden>
> Signed-off-by: Marc-André Lureau <address@hidden>
We can drop the error at all if there is a comment. Also, "volatile
sig_atomic_t" is probably self-explanatory and usually correct. So what about
this:
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f5a523af10..3dc27d9656 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2475,13 +2475,11 @@ sub process {
# no volatiles please
my $asm_volatile =
qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
- if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
- my $msg = "Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt\n" . $herecurr;
- if (ctx_has_comment($first_line, $linenr)) {
- WARN($msg);
- } else {
- ERROR($msg);
- }
+ if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/ &&
+ $line !~ /sig_atomic_t/ &&
+ !ctx_has_comment($first_line, $linenr)) {
+ my $msg = "Use of volatile is usually wrong, please add
a comment\n" . $herecurr;
+ ERROR($msg);
}
# warn about #if 0