lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABJPP5AodovE61WiEup_191pVwptEzg8sVuG6QxeMVbM94wpNw@mail.gmail.com>
Date:   Sun, 29 Nov 2020 00:34:40 +0530
From:   Dwaipayan Ray <dwaipayanray1@...il.com>
To:     Joe Perches <joe@...ches.com>
Cc:     linux-kernel-mentees@...ts.linuxfoundation.org,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Lukas Bulwahn <lukas.bulwahn@...il.com>
Subject: Re: [PATCH v3] checkpatch: add warning for unnecessary use of
 %h[xudi] and %hh[xudi]

> Here was what I tried:
>
> There are uses like %#06hh", so # was addedto the format block
> and multiple line uses were also inspected.
>
>
>  scripts/checkpatch.pl | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7dc094445d83..b985b6b37ba8 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -6027,6 +6027,29 @@ sub process {
>                              "Avoid logging continuation uses where feasible\n" . $herecurr);
>                 }
>
> +# check for unnecessary use of %h[xudi] and %hh[xudi] in logging functions
> +               if (defined $stat &&
> +                   $line =~ /\b$logFunctions\s*\(/ &&
> +                   index($stat, '"') >= 0) {
> +                       my $lc = $stat =~ tr@\n@@;
> +                       $lc = $lc + $linenr;
> +                       my $stat_real = get_stat_real($linenr, $lc);
> +                       pos($stat_real) = index($stat_real, '"');
> +                       my $lineoff = substr($stat_real, 0, pos($stat_real)) =~ tr/\n//;
> +                       while ($stat_real =~ /[^"%]*(%[#\d\.\*\-]*(h+)[idux])/g) {
> +                               my $pspec = $1;
> +                               my $h = $2;
> +                               if (WARN("UNNECESSARY_MODIFIER",
> +                                        "Integer promotion: '$h' use in '$pspec' is unnecessary\n" . "$here\n$stat_real\n") &&
> +                                   $fix &&
> +                                   $fixed[$fixlinenr + $lineoff] =~ /^\+/) {
> +                                       my $nspec = $pspec;
> +                                       $nspec =~ s/h//g;
> +                                       $fixed[$fixlinenr + $lineoff] =~ s/\Q$pspec\E/$nspec/;
> +                               }
> +                       }
> +               }
> +
>  # check for mask then right shift without a parentheses
>                 if ($perl_version_ok &&
>                     $line =~ /$LvalOrFunc\s*\&\s*($LvalOrFunc)\s*>>/ &&
>

Thanks, I will modify the block according to this and send it back to you.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ