1
0
Fork 0

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>
hifive-unleashed-5.1
Tobin C. Harding 2018-01-29 14:33:49 +11:00
parent 6efb745828
commit 5eb0da0568
1 changed files with 14 additions and 12 deletions

View File

@ -170,24 +170,26 @@ sub is_supported_architecture
return (is_x86_64() or is_ppc64());
}
sub is_arch
{
my ($desc) = @_;
my $arch = `uname -m`;
chomp $arch;
if ($arch eq $desc) {
return 1;
}
return 0;
}
sub is_x86_64
{
my $archname = `uname -m`;
if ($archname =~ m/x86_64/) {
return 1;
}
return 0;
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.