mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 04:55:51 +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
64cad2fa07
commit
43838492af
@ -48,12 +48,16 @@ close(FORMAT_FILE);
|
||||
$/ = $line_separator;
|
||||
|
||||
my @files = <$include_dir/*.h>;
|
||||
my @necessary_include_files;
|
||||
my @matches;
|
||||
foreach my $file (@files) {
|
||||
open(FILE, "$file");
|
||||
my @grep_res = grep(/^\s*#define\s+MBEDTLS_ERR_\w+\s+\-0x[0-9A-Fa-f]+/, <FILE>);
|
||||
push(@matches, @grep_res);
|
||||
close FILE;
|
||||
my $include_name = $file;
|
||||
$include_name =~ s!.*/!!;
|
||||
push @necessary_include_files, $include_name if @grep_res;
|
||||
}
|
||||
|
||||
my $ll_old_define = "";
|
||||
@ -63,10 +67,10 @@ my $ll_code_check = "";
|
||||
my $hl_code_check = "";
|
||||
|
||||
my $headers = "";
|
||||
my %included_headers;
|
||||
|
||||
my %error_codes_seen;
|
||||
|
||||
|
||||
foreach my $line (@matches)
|
||||
{
|
||||
next if ($line =~ /compat-1.2.h/);
|
||||
@ -102,6 +106,8 @@ foreach my $line (@matches)
|
||||
# Fix faulty ones
|
||||
$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_hl = grep $_ eq $module_name, @high_level_modules;
|
||||
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': $!";
|
||||
print ERROR_FILE $error_format;
|
||||
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