]> Git Repo - qemu.git/commitdiff
checkpatch: volatile with a comment or sig_atomic_t is okay
authorMarc-André Lureau <[email protected]>
Fri, 15 Dec 2017 18:18:10 +0000 (19:18 +0100)
committerPaolo Bonzini <[email protected]>
Thu, 21 Dec 2017 08:30:32 +0000 (09:30 +0100)
This assumes that the comment gives some justification;
"volatile sig_atomic_t" is also self-explanatory and usually
correct.

Discussed in:
'[Qemu-devel] [PATCH] dump-guest-memory.py: fix "You can't do that without a process to debug"'

Suggested-by: Fam Zheng <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20171215181810[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
scripts/checkpatch.pl

index 34df75357149382d5bbcb4c073f5867137d12891..3dc27d9656d52076d176eda4b6c818b5e9752150 100755 (executable)
@@ -2475,8 +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/) {
-                       ERROR("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
+               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
This page took 0.028918 seconds and 4 git commands to generate.