Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1544134 > unrolled thread

[PATCH] scripts: checkincludes: add exit message for no duplicates found

Started byCheah Kok Cheong <thrust73@gmail.com>
First post2016-12-18 13:40 +0100
Last post2016-12-20 10:20 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] scripts: checkincludes: add exit message for no duplicates found Cheah Kok Cheong <thrust73@gmail.com> - 2016-12-18 13:40 +0100
    Re: [PATCH] scripts: checkincludes: add exit message for no  duplicates found Michal Marek <mmarek@suse.com> - 2016-12-19 11:50 +0100
      Re: [PATCH] scripts: checkincludes: add exit message for no  duplicates found Cheah Kok Cheong <thrust73@gmail.com> - 2016-12-20 10:20 +0100

#1544134 — [PATCH] scripts: checkincludes: add exit message for no duplicates found

FromCheah Kok Cheong <thrust73@gmail.com>
Date2016-12-18 13:40 +0100
Subject[PATCH] scripts: checkincludes: add exit message for no duplicates found
Message-ID<sPIUW-7Lp-9@gated-at.bofh.it>
If no duplicates found, inform user.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
---
 scripts/checkincludes.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/scripts/checkincludes.pl b/scripts/checkincludes.pl
index 97b2c61..2bf234c 100755
--- a/scripts/checkincludes.pl
+++ b/scripts/checkincludes.pl
@@ -37,6 +37,13 @@ if ($#ARGV >= 1) {
 	}
 }
 
+my $dup_counter = 0;
+
+sub nodup_count {
+	++$dup_counter;
+	return;
+}
+
 foreach my $file (@ARGV) {
 	open(my $f, '<', $file)
 	    or die "Cannot open $file: $!.\n";
@@ -57,6 +64,7 @@ foreach my $file (@ARGV) {
 		foreach my $filename (keys %includedfiles) {
 			if ($includedfiles{$filename} > 1) {
 				print "$file: $filename is included more than once.\n";
+				nodup_count();
 			}
 		}
 		next;
@@ -73,6 +81,7 @@ foreach my $file (@ARGV) {
 					if ($includedfiles{$filename} > 1) {
 						$includedfiles{$filename}--;
 						$dups++;
+						nodup_count();
 					} else {
 						print {$f} $_;
 					}
@@ -87,3 +96,7 @@ foreach my $file (@ARGV) {
 	}
 	close($f);
 }
+
+if ($dup_counter == 0) {
+	print "No duplicate includes found.\n";
+}
-- 
2.7.4

[toc] | [next] | [standalone]


#1544448 — Re: [PATCH] scripts: checkincludes: add exit message for no duplicates found

FromMichal Marek <mmarek@suse.com>
Date2016-12-19 11:50 +0100
SubjectRe: [PATCH] scripts: checkincludes: add exit message for no duplicates found
Message-ID<sQ3G2-6zz-23@gated-at.bofh.it>
In reply to#1544134
On 2016-12-18 13:35, Cheah Kok Cheong wrote:
> If no duplicates found, inform user.
> 
> Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
> ---
>  scripts/checkincludes.pl | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/scripts/checkincludes.pl b/scripts/checkincludes.pl
> index 97b2c61..2bf234c 100755
> --- a/scripts/checkincludes.pl
> +++ b/scripts/checkincludes.pl
> @@ -37,6 +37,13 @@ if ($#ARGV >= 1) {
>  	}
>  }
>  
> +my $dup_counter = 0;
> +
> +sub nodup_count {
> +	++$dup_counter;
> +	return;
> +}

I don't think it's necessary to have a function only to increment a
variable.

Michal

[toc] | [prev] | [next] | [standalone]


#1544991 — Re: [PATCH] scripts: checkincludes: add exit message for no duplicates found

FromCheah Kok Cheong <thrust73@gmail.com>
Date2016-12-20 10:20 +0100
SubjectRe: [PATCH] scripts: checkincludes: add exit message for no duplicates found
Message-ID<sQoKu-3Gs-17@gated-at.bofh.it>
In reply to#1544448
On Mon, Dec 19, 2016 at 11:47:47AM +0100, Michal Marek wrote:
> On 2016-12-18 13:35, Cheah Kok Cheong wrote:
> > If no duplicates found, inform user.
> > 
> > Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
> > ---
> >  scripts/checkincludes.pl | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> > 
> > diff --git a/scripts/checkincludes.pl b/scripts/checkincludes.pl
> > index 97b2c61..2bf234c 100755
> > --- a/scripts/checkincludes.pl
> > +++ b/scripts/checkincludes.pl
> > @@ -37,6 +37,13 @@ if ($#ARGV >= 1) {
> >  	}
> >  }
> >  
> > +my $dup_counter = 0;
> > +
> > +sub nodup_count {
> > +	++$dup_counter;
> > +	return;
> > +}
> 
> I don't think it's necessary to have a function only to increment a
> variable.
> 
> Michal

Sorry do you mean the subroutine is not required and the "variable" is
best placed inside directly?

Thanks.
CheahKC

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web