Skip to contentSkip to conversation

checkpatch: volatile with a comment or sig_atomic_t is okay

PATCH In review Paolo Bonzini 3 participants 4 messages Dec 18, 2017 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpatch: volatile with a comment or sig_atomic_t is okay

From: Marc-André Lureau <[email protected]>

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"'

Message-Id: <[email protected]>

---
 scripts/checkpatch.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +5 -2
index 34df753571..3dc27d9656 100755
@@ -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
Signature · 1 line
2.14.3
#1 lore raw

Hi

----- Original Message -----

Quoted 6 lines

From: Marc-André Lureau <[email protected]>

This assumes that the comment gives some justification; "volatile sig_atomic_t" is also self-explanatory and usually correct.

Quoted 8 lines

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

Message-Id: <[email protected]>

Thanks, I can add it to my 2 patches series for dump (to avoid error on Peter's end)

Unless you send a pull request with it sonnish

Quoted 28 lines
---
 scripts/checkpatch.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +5 -2
index 34df753571..3dc27d9656 100755
@@ -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
--
2.14.3
#2 lore raw
Quoted 13 lines · Marc-André Lureau

Hi

----- Original Message -----

Quoted 10 lines

From: Marc-André Lureau <[email protected]>

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"'

Quoted 8 lines
Quoted 4 lines

Message-Id: <[email protected]>

Thanks, I can add it to my 2 patches series for dump (to avoid error on Peter's end)

Unless you send a pull request with it sonnish

It is not a big deal if it is included twice. I'm planning my pull request for tomorrow or Wednesday.

Paolo

Quoted 30 lines
Quoted 30 lines

---
 scripts/checkpatch.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +5 -2
index 34df753571..3dc27d9656 100755
@@ -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
--
2.14.3
#3 lore raw
In reply to Paolo Bonzini
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v2] checkpatch: volatile with a comment or sig_atomic_t is okay

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
ac1ea4c622 checkpatch: volatile with a comment or sig_atomic_t is okay

=== OUTPUT BEGIN ===
Checking PATCH 1/1: checkpatch: volatile with a comment or sig_atomic_t is okay...
ERROR: line over 90 characters
#35: FILE: scripts/checkpatch.pl:2481:
+ my $msg = "Use of volatile is usually wrong, please add a comment\n" . $herecurr;

total: 1 errors, 0 warnings, 13 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]