On Thu, 2020-10-22 at 20:20 +0530, Aditya Srivastava wrote:
> Presence of hexadecimal address or symbol results in false warning
> message by checkpatch.pl.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3051,7 +3051,10 @@ sub process {
>               }
>  
>  # check for repeated words separated by a single space
> -             if ($rawline =~ /^\+/ || $in_commit_log) {
> +# avoid false positive from list command eg, '-rw-r--r-- 1 root root'
> +             if (($rawline =~ /^\+/ || $in_commit_log) &&
> +             $rawline !~ /[bcCdDlMnpPs\?-][rwxsStT-]{9}/) {

Alignment and use \b before and after the regex please.

                if (($rawline =~ /^\+/ || $in_commit_log) &&
                    $rawline !~ /\b[bcCdDlMnpPs\?-][rwxsStT-]{9}\b/) {
> @@ -3065,6 +3068,34 @@ sub process {
>                               next if ($first ne $second);
>                               next if ($first eq 'long');
>  
> +                             # avoid repeating hex occurrences like 'ff ff 
> fe 09 ...'
> +                             if ($first =~ /\b[0-9a-f]{2,}/) {
> +                                     # if such sequence occurs more than 4, 
> it is most probably part of some of code
> +                                     next if ((scalar @hex_seq)>4);
> +                                     # for hex occurrences which are less 
> than 4
> +                                     # get first hex word in the line
> +                                     if ($rawline =~ /\b[0-9a-f]{2,} /) {
> +                                             my $post_hex_seq = $';
> +
> +                                             # set suffieciently high 
> default values to avoid ignoring or counting in absence of another
> +                                             my $non_hex_char_pos = 1000;
> +                                             my $special_chars_pos = 500;
> +
> +                                             if ($post_hex_seq =~ /[g-z]+/) {
> +                                                     # first non hex 
> character in post_hex_seq
> +                                                     $non_hex_char_pos = 
> $-[0];
> +                                             }
> +                                             if($post_hex_seq =~ 
> /[^a-zA-Z0-9]{2,}/) {
> +                                                     # first occurrence of 2 
> or more special chars
> +                                                     $special_chars_pos = 
> $-[0];
> +                                             }

What does all this code actually avoid?


Reply via email to