]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
leaking_addresses: add is_arch() wrapper subroutine
authorTobin C. Harding <me@tobin.cc>
Mon, 29 Jan 2018 03:33:49 +0000 (14:33 +1100)
committerTobin C. Harding <me@tobin.cc>
Fri, 6 Apr 2018 22:50:34 +0000 (08:50 +1000)
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>
scripts/leaking_addresses.pl

index 56894daf6368f423b17445f48d08896b750ce7e8..e5b418cca1859af418f372d9ed6b12d7e2b91ece 100755 (executable)
@@ -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.