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]
Date:   Thu, 28 Jan 2021 11:11:05 -0800
From:   Joe Perches <joe@...ches.com>
To:     Dwaipayan Ray <dwaipayanray1@...il.com>
Cc:     linux-kernel-mentees@...ts.linuxfoundation.org,
        lukas.bulwahn@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/3] checkpatch: add verbose mode

On Thu, 2021-01-28 at 20:08 +0530, Dwaipayan Ray wrote:
> Add a new verbose mode to checkpatch.pl to emit additional verbose
> test descriptions. The verbose mode is optional and can be enabled
> by the flag -v or --verbose.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[] 
> +sub load_docs {
> +	open(my $docs, '<', "$docsfile")
> +	    or warn "$P: Can't read the documentation file $docsfile $!\n";
> +
> +	my @lines = ();
> +	while (<$docs>) {
> +		my $line = $_;
> +
> +		$line =~ s/\s*\n?$//g;

chomp

> +		push (@lines, $line);
> +	}
> +	close($docs);
> +
> +	my $linenr = 0;
> +	my $cnt = scalar @lines;
> +	while ($linenr < $cnt) {
> +		while ($linenr < $cnt &&
> +		       $lines[$linenr++] !~ /^\:(.+)\:$/)
> +		{
> +		}
> +
> +		last if ($linenr >= $cnt);
> +
> +		my $type = $lines[$linenr - 1];
> +		$type =~ s/^\:(.+)\:$/$1/;
> +		my $message = '';
> +
> +		while ($linenr < $cnt &&
> +		       $lines[$linenr] =~ /^(?:\s+(.+)$|$)/) {
> +			$message .= $1 if (defined $1);
> +			$message .= "\n";
> +			$linenr++;
> +		}
> +
> +		$message = trim($message);
> +		$verbose_messages{$type} = $message;
> +	}
> +}

I think this is overly complicated.

There's no need to read and store the entire file and then
parse it.  Just parse it line by line as its read.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ