lkml.org 
[lkml]   [2007]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] scripts/checkpatch.pl: add a check for the patch level (patch -p<num>)
On Tue, Dec 18, 2007 at 06:46:41AM +0100, Borislav Petkov wrote:
> On Mon, Dec 17, 2007 at 08:11:05AM +0100, Borislav Petkov wrote:
>
> A slightly microoptimized version 1.1:
>
> ---
> From: Borislav Petkov <bbpetkov@yahoo.de>
>
>
> Check the patch level of the single hunks in a patch file, however only when
> checkpatch.pl is called from within the kernel tree.
>
> Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
> --
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 579f50f..3eda27b 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -653,6 +653,18 @@ sub CHK {
> }
> }
>
> +sub check_patchlevel {
> +
> + if ($tree) {
> + my ($path) = @_;
> + $path =~ s![^/]*/!!;
> +
> + if (!stat($path)) {
> + WARN("Check the patchlevel (hint: patch option -p)");
> + }
> + }

Hmmm that will trigger on all patches which create new files if I am
grokking you correctly.

I would have thought this would pretty easy to check from the form of
the names. Hmmm.

> +}
> +
> sub process {
> my $filename = shift;
> my @lines = @_;
> @@ -713,10 +725,16 @@ sub process {
> #extract the filename as it passes
> if ($line=~/^\+\+\+\s+(\S+)/) {
> $realfile=$1;
> +
> + if ($realfile) {
> + check_patchlevel($realfile);
> + }
> +
> $realfile =~ s@^[^/]*/@@;
> $in_comment = 0;
> next;
> }
> +
> #extract the line range in the file after the patch is applied
> if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
> $is_patch = 1;

-apw


\
 
 \ /
  Last update: 2007-12-21 19:15    [W:0.060 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site