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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210327071641.1485896-1-wanjiabing@vivo.com>
Date:   Sat, 27 Mar 2021 15:16:36 +0800
From:   Wan Jiabing <wanjiabing@...o.com>
To:     Wan Jiabing <wanjiabing@...o.com>, linux-kernel@...r.kernel.org
Cc:     kael_w@...h.net
Subject: [PATCH] scripts: checkdeclares for checking duplicate struct declares

checkdeclares: find struct declared more than once.
Inspired by checkincludes.pl
This script checks for duplicate struct declares.
Note that this will not take into consideration macros so
you should run this only if you know you do have real dups
and do not have them under #ifdef's.
You could also just review the results.

Signed-off-by: Wan Jiabing <wanjiabing@...o.com>
---
 scripts/checkdeclares.pl | 55 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100755 scripts/checkdeclares.pl

diff --git a/scripts/checkdeclares.pl b/scripts/checkdeclares.pl
new file mode 100755
index 000000000000..f28c40ab0f00
--- /dev/null
+++ b/scripts/checkdeclares.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
+#
+# checkdeclares: find struct declared more than once
+#
+# Copyright 2021 Wan Jiabing<wanjiabing@...o.com>
+# Inspired by checkincludes.pl
+#
+# This script checks for duplicate struct declares.
+# Note that this will not take into consideration macros so
+# you should run this only if you know you do have real dups
+# and do not have them under #ifdef's.
+# You could also just review the results.
+
+use strict;
+
+sub usage {
+	print "Usage: checkdeclares.pl \n";
+	print "We just warn of struct declaration duplicates\n";
+	exit 1;
+}
+
+if ($#ARGV < 0) {
+	usage();
+}
+
+my $dup_counter = 0;
+
+foreach my $file (@ARGV) {
+	open(my $f, '<', $file)
+	    or die "Cannot open $file: $!.\n";
+
+	my %declaredfiles = ();
+	my @file_lines = ();
+
+	while (<$f>) {
+		if (m/^\s*struct\s*(\w*);$/o) {
+			++$declaredfiles{$1};
+		}
+		push(@file_lines, $_);
+	}
+
+	close($f);
+
+	foreach my $filename (keys %declaredfiles) {
+		if ($declaredfiles{$filename} > 1) {
+			print "$file: struct $filename is declared more than once.\n";
+			++$dup_counter;
+		}
+	}
+}
+
+if ($dup_counter == 0) {
+	print "No duplicate struct declares found.\n";
+}
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ