Patchwork [6/6] checkpatch: warn about queue/queue.h head structs that are not typedef-ed

login
register
mail settings
Submitter Paolo Bonzini
Date Dec. 6, 2018, 11:23 p.m.
Message ID <20181206232333.22408-7-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/674829/
State New
Headers show

Comments

Paolo Bonzini - Dec. 6, 2018, 11:23 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)
Markus Armbruster - Dec. 7, 2018, 9:02 a.m.
Let's state the rationale for requiring a typedef in the commit
message, or point to a prior commit that has it.

Paolo Bonzini <pbonzini@redhat.com> writes:

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/checkpatch.pl | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index a8d6e44107..b4b3495044 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2263,6 +2263,11 @@ sub process {
>  			}
>  		}
>  
> +		if ($line =~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ &&
> +		    $line !~ /^.typedef/) {
> +		    ERROR("named $1 should be typedefed separately\n" . $herecurr);
> +		}
> +
>  # Need a space before open parenthesis after if, while etc
>  		if ($line=~/\b(if|while|for|switch)\(/) {
>  			ERROR("space required before the open parenthesis '('\n" . $herecurr);
Paolo Bonzini - Dec. 7, 2018, 1:49 p.m.
On 07/12/18 10:02, Markus Armbruster wrote:
> Let's state the rationale for requiring a typedef in the commit
> message, or point to a prior commit that has it.

Sure---the rationale is simply that they are structs (or unions in the
case of QTAILQ but it's just an implementation detail), and we use
typedef for structs.

Paolo

> Paolo Bonzini <pbonzini@redhat.com> writes:
> 
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  scripts/checkpatch.pl | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index a8d6e44107..b4b3495044 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -2263,6 +2263,11 @@ sub process {
>>  			}
>>  		}
>>  
>> +		if ($line =~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ &&
>> +		    $line !~ /^.typedef/) {
>> +		    ERROR("named $1 should be typedefed separately\n" . $herecurr);
>> +		}
>> +
>>  # Need a space before open parenthesis after if, while etc
>>  		if ($line=~/\b(if|while|for|switch)\(/) {
>>  			ERROR("space required before the open parenthesis '('\n" . $herecurr);

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a8d6e44107..b4b3495044 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2263,6 +2263,11 @@  sub process {
 			}
 		}
 
+		if ($line =~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ &&
+		    $line !~ /^.typedef/) {
+		    ERROR("named $1 should be typedefed separately\n" . $herecurr);
+		}
+
 # Need a space before open parenthesis after if, while etc
 		if ($line=~/\b(if|while|for|switch)\(/) {
 			ERROR("space required before the open parenthesis '('\n" . $herecurr);