diff options
author | Tobin C. Harding <me@tobin.cc> | 2018-01-28 22:33:49 -0500 |
---|---|---|
committer | Tobin C. Harding <me@tobin.cc> | 2018-04-06 18:50:34 -0400 |
commit | 5eb0da0568a241f72732eb2143538fb14879a52c (patch) | |
tree | 720254a6a378c39737ada94f27eec7c49cd7c6b7 /scripts/leaking_addresses.pl | |
parent | 6efb7458280a8f5d4c1955324e9d8985e90a882b (diff) |
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>
Diffstat (limited to 'scripts/leaking_addresses.pl')
-rwxr-xr-x | scripts/leaking_addresses.pl | 26 |
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 | |||
170 | return (is_x86_64() or is_ppc64()); | 170 | return (is_x86_64() or is_ppc64()); |
171 | } | 171 | } |
172 | 172 | ||
173 | sub is_x86_64 | 173 | sub is_arch |
174 | { | 174 | { |
175 | my $archname = `uname -m`; | 175 | my ($desc) = @_; |
176 | my $arch = `uname -m`; | ||
177 | |||
178 | chomp $arch; | ||
179 | if ($arch eq $desc) { | ||
180 | return 1; | ||
181 | } | ||
182 | return 0; | ||
183 | } | ||
176 | 184 | ||
177 | if ($archname =~ m/x86_64/) { | 185 | sub is_x86_64 |
178 | return 1; | 186 | { |
179 | } | 187 | return is_arch('x86_64'); |
180 | return 0; | ||
181 | } | 188 | } |
182 | 189 | ||
183 | sub is_ppc64 | 190 | sub is_ppc64 |
184 | { | 191 | { |
185 | my $archname = `uname -m`; | 192 | return is_arch('ppc64'); |
186 | |||
187 | if ($archname =~ m/ppc64/) { | ||
188 | return 1; | ||
189 | } | ||
190 | return 0; | ||
191 | } | 193 | } |
192 | 194 | ||
193 | # Gets config option value from kernel config file. | 195 | # Gets config option value from kernel config file. |