2 # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
9 # This is just a quick script to scan for cases where the 'error'
10 # function name in a XXXerr() macro is wrong.
12 # Run in the top level by going
13 # perl util/ck_errf.pl */*.c */*/*.c
22 # To detect if there is any error generation for a libcrypto/libssl libs
23 # we don't know, we need to find out what libs we do know. That list is
24 # readily available in crypto/err/openssl.ec, in form of lines starting
26 my $config = "crypto/err/openssl.ec";
27 my %libs = ( "SYS" => 1 );
28 open my $cfh, $config or die "Trying to read $config: $!\n";
30 s|\R$||; # Better chomp
31 next unless m|^L ([0-9A-Z_]+)\s|;
36 foreach my $file (@ARGV) {
37 if ( $file eq "-strict" ) {
41 open( IN, "<$file" ) || die "Can't open $file, $!";
44 if ( !/;$/ && /^\**([a-zA-Z_].*[\s*])?([A-Za-z_0-9]+)\(.*([),]|$)/ ) {
45 /^([^()]*(\([^()]*\)[^()]*)*)\(/;
46 $1 =~ /([A-Za-z_0-9]*)$/;
50 if ( /([A-Z0-9_]+[A-Z0-9])err\(([^,]+)/ && !/ckerr_ignore/ ) {
54 unless ( $libs{$errlib} ) {
55 print "$file:$.:$errlib unknown\n";
60 print "$file:$.:???:$n\n";
65 if ( $n !~ /^(.+)_F_(.+)$/ ) {
66 #print "check -$file:$.:$func:$n\n";
72 if ( $lib ne $errlib ) {
73 print "$file:$.:$func:$n [${errlib}err]\n";
79 if ( $n ne $func && $errlib ne "SYS" ) {
80 print "$file:$.:$func:$n\n";
91 if ( $bad && $err_strict ) {
92 print STDERR "FATAL: error discrepancy\n";