mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 03:25:46 +01:00
Check that all necessary headers are included in error.c
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
c64d847127
commit
4f84cc7d67
@ -48,12 +48,16 @@ close(FORMAT_FILE);
|
|||||||
$/ = $line_separator;
|
$/ = $line_separator;
|
||||||
|
|
||||||
my @files = <$include_dir/*.h>;
|
my @files = <$include_dir/*.h>;
|
||||||
|
my @necessary_include_files;
|
||||||
my @matches;
|
my @matches;
|
||||||
foreach my $file (@files) {
|
foreach my $file (@files) {
|
||||||
open(FILE, "$file");
|
open(FILE, "$file");
|
||||||
my @grep_res = grep(/^\s*#define\s+MBEDTLS_ERR_\w+\s+\-0x[0-9A-Fa-f]+/, <FILE>);
|
my @grep_res = grep(/^\s*#define\s+MBEDTLS_ERR_\w+\s+\-0x[0-9A-Fa-f]+/, <FILE>);
|
||||||
push(@matches, @grep_res);
|
push(@matches, @grep_res);
|
||||||
close FILE;
|
close FILE;
|
||||||
|
my $include_name = $file;
|
||||||
|
$include_name =~ s!.*/!!;
|
||||||
|
push @necessary_include_files, $include_name if @grep_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ll_old_define = "";
|
my $ll_old_define = "";
|
||||||
@ -63,10 +67,10 @@ my $ll_code_check = "";
|
|||||||
my $hl_code_check = "";
|
my $hl_code_check = "";
|
||||||
|
|
||||||
my $headers = "";
|
my $headers = "";
|
||||||
|
my %included_headers;
|
||||||
|
|
||||||
my %error_codes_seen;
|
my %error_codes_seen;
|
||||||
|
|
||||||
|
|
||||||
foreach my $line (@matches)
|
foreach my $line (@matches)
|
||||||
{
|
{
|
||||||
next if ($line =~ /compat-1.2.h/);
|
next if ($line =~ /compat-1.2.h/);
|
||||||
@ -102,6 +106,8 @@ foreach my $line (@matches)
|
|||||||
# Fix faulty ones
|
# Fix faulty ones
|
||||||
$include_name = "net_sockets" if ($module_name eq "NET");
|
$include_name = "net_sockets" if ($module_name eq "NET");
|
||||||
|
|
||||||
|
$included_headers{"${include_name}.h"} = $module_name;
|
||||||
|
|
||||||
my $found_ll = grep $_ eq $module_name, @low_level_modules;
|
my $found_ll = grep $_ eq $module_name, @low_level_modules;
|
||||||
my $found_hl = grep $_ eq $module_name, @high_level_modules;
|
my $found_hl = grep $_ eq $module_name, @high_level_modules;
|
||||||
if (!$found_ll && !$found_hl)
|
if (!$found_ll && !$found_hl)
|
||||||
@ -205,3 +211,15 @@ $error_format =~ s/HIGH_LEVEL_CODE_CHECKS\n/$hl_code_check/g;
|
|||||||
open(ERROR_FILE, ">$error_file") or die "Opening destination file '$error_file': $!";
|
open(ERROR_FILE, ">$error_file") or die "Opening destination file '$error_file': $!";
|
||||||
print ERROR_FILE $error_format;
|
print ERROR_FILE $error_format;
|
||||||
close(ERROR_FILE);
|
close(ERROR_FILE);
|
||||||
|
|
||||||
|
my $errors = 0;
|
||||||
|
for my $include_name (@necessary_include_files)
|
||||||
|
{
|
||||||
|
if (not $included_headers{$include_name})
|
||||||
|
{
|
||||||
|
print STDERR "The header file \"$include_name\" defines error codes but has not been included!\n";
|
||||||
|
++$errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit !!$errors;
|
||||||
|
Loading…
Reference in New Issue
Block a user