]>
Commit | Line | Data |
---|---|---|
e0a65194 RS |
1 | #! /usr/bin/env perl |
2 | # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. | |
d02b48c6 | 3 | # |
e0a65194 RS |
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 | |
8 | ||
d02b48c6 RE |
9 | # This is just a quick script to scan for cases where the 'error' |
10 | # function name in a XXXerr() macro is wrong. | |
609b0852 | 11 | # |
d02b48c6 RE |
12 | # Run in the top level by going |
13 | # perl util/ck_errf.pl */*.c */*/*.c | |
14 | # | |
15 | ||
5038e325 RS |
16 | use strict; |
17 | use warnings; | |
18 | ||
3ed3603b | 19 | my $err_strict = 0; |
5038e325 RS |
20 | my $bad = 0; |
21 | ||
22 | foreach my $file (@ARGV) { | |
23 | if ( $file eq "-strict" ) { | |
24 | $err_strict = 1; | |
25 | next; | |
26 | } | |
27 | open( IN, "<$file" ) || die "Can't open $file, $!"; | |
28 | my $func = ""; | |
29 | while (<IN>) { | |
30 | if ( !/;$/ && /^\**([a-zA-Z_].*[\s*])?([A-Za-z_0-9]+)\(.*([),]|$)/ ) { | |
31 | /^([^()]*(\([^()]*\)[^()]*)*)\(/; | |
32 | $1 =~ /([A-Za-z_0-9]*)$/; | |
33 | $func = $1; | |
34 | $func =~ tr/A-Z/a-z/; | |
35 | } | |
36 | if ( /([A-Z0-9]+)err\(([^,]+)/ && !/ckerr_ignore/ ) { | |
37 | my $errlib = $1; | |
38 | my $n = $2; | |
3ed3603b | 39 | |
5038e325 RS |
40 | if ( $func eq "" ) { |
41 | print "$file:$.:???:$n\n"; | |
42 | $bad = 1; | |
43 | next; | |
44 | } | |
8afca8d9 | 45 | |
5038e325 RS |
46 | if ( $n !~ /([^_]+)_F_(.+)$/ ) { |
47 | #print "check -$file:$.:$func:$n\n"; | |
48 | next; | |
49 | } | |
50 | my $lib = $1; | |
51 | $n = $2; | |
8afca8d9 | 52 | |
5038e325 RS |
53 | if ( $lib ne $errlib ) { |
54 | print "$file:$.:$func:$n [${errlib}err]\n"; | |
55 | $bad = 1; | |
56 | next; | |
57 | } | |
d02b48c6 | 58 | |
5038e325 RS |
59 | $n =~ tr/A-Z/a-z/; |
60 | if ( $n ne $func && $errlib ne "SYS" ) { | |
61 | print "$file:$.:$func:$n\n"; | |
62 | $bad = 1; | |
63 | next; | |
64 | } | |
d02b48c6 | 65 | |
5038e325 | 66 | # print "$func:$1\n"; |
d02b48c6 | 67 | } |
5038e325 RS |
68 | } |
69 | close(IN); | |
70 | } | |
d02b48c6 | 71 | |
5038e325 RS |
72 | if ( $bad && $err_strict ) { |
73 | print STDERR "FATAL: error discrepancy\n"; | |
74 | exit 1; | |
75 | } |