summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobin C. Harding <me@tobin.cc>2018-01-29 04:33:49 +0100
committerTobin C. Harding <me@tobin.cc>2018-04-07 00:50:34 +0200
commit5eb0da0568a241f72732eb2143538fb14879a52c (patch)
tree720254a6a378c39737ada94f27eec7c49cd7c6b7
parentleaking_addresses: use system command to get arch (diff)
downloadlinux-5eb0da0568a241f72732eb2143538fb14879a52c.tar.xz
linux-5eb0da0568a241f72732eb2143538fb14879a52c.zip
leaking_addresses: add is_arch() wrapper subroutine
Currently there is duplicate code when checking the architecture type. We can remove the duplication by implementing a wrapper function is_arch(). Implement and use wrapper function is_arch(). Signed-off-by: Tobin C. Harding <me@tobin.cc>
-rwxr-xr-xscripts/leaking_addresses.pl26
1 files changed, 14 insertions, 12 deletions
diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index 56894daf6368..e5b418cca185 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -170,24 +170,26 @@ sub is_supported_architecture
return (is_x86_64() or is_ppc64());
}
-sub is_x86_64
+sub is_arch
{
- my $archname = `uname -m`;
+ my ($desc) = @_;
+ my $arch = `uname -m`;
+
+ chomp $arch;
+ if ($arch eq $desc) {
+ return 1;
+ }
+ return 0;
+}
- if ($archname =~ m/x86_64/) {
- return 1;
- }
- return 0;
+sub is_x86_64
+{
+ return is_arch('x86_64');
}
sub is_ppc64
{
- my $archname = `uname -m`;
-
- if ($archname =~ m/ppc64/) {
- return 1;
- }
- return 0;
+ return is_arch('ppc64');
}
# Gets config option value from kernel config file.