1 1.1.1.4 christos #! /usr/bin/env perl 2 1.1.1.4 christos # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos # 4 1.1.1.4 christos # Licensed under the OpenSSL license (the "License"). You may not use 5 1.1.1.4 christos # this file except in compliance with the License. You can obtain a copy 6 1.1.1.4 christos # in the file LICENSE in the source distribution or at 7 1.1.1.4 christos # https://www.openssl.org/source/license.html 8 1.1.1.4 christos 9 1.1 christos # This is just a quick script to scan for cases where the 'error' 10 1.1 christos # function name in a XXXerr() macro is wrong. 11 1.1 christos # 12 1.1 christos # Run in the top level by going 13 1.1 christos # perl util/ck_errf.pl */*.c */*/*.c 14 1.1 christos # 15 1.1 christos 16 1.1.1.2 christos my $err_strict = 0; 17 1.1.1.2 christos my $bad = 0; 18 1.1.1.2 christos 19 1.1 christos foreach $file (@ARGV) 20 1.1 christos { 21 1.1.1.2 christos if ($file eq "-strict") 22 1.1.1.2 christos { 23 1.1.1.2 christos $err_strict = 1; 24 1.1.1.2 christos next; 25 1.1.1.2 christos } 26 1.1 christos open(IN,"<$file") || die "unable to open $file\n"; 27 1.1 christos $func=""; 28 1.1 christos while (<IN>) 29 1.1 christos { 30 1.1.1.4 christos if (!/;$/ && /^\**([a-zA-Z_].*[\s*])?([A-Za-z_0-9]+)\(.*([),]|$)/) 31 1.1 christos { 32 1.1 christos /^([^()]*(\([^()]*\)[^()]*)*)\(/; 33 1.1 christos $1 =~ /([A-Za-z_0-9]*)$/; 34 1.1 christos $func = $1; 35 1.1 christos $func =~ tr/A-Z/a-z/; 36 1.1 christos } 37 1.1 christos if (/([A-Z0-9]+)err\(([^,]+)/ && ! /ckerr_ignore/) 38 1.1 christos { 39 1.1 christos $errlib=$1; 40 1.1 christos $n=$2; 41 1.1 christos 42 1.1 christos if ($func eq "") 43 1.1.1.2 christos { print "$file:$.:???:$n\n"; $bad = 1; next; } 44 1.1 christos 45 1.1 christos if ($n !~ /([^_]+)_F_(.+)$/) 46 1.1 christos { 47 1.1 christos # print "check -$file:$.:$func:$n\n"; 48 1.1 christos next; 49 1.1 christos } 50 1.1 christos $lib=$1; 51 1.1 christos $n=$2; 52 1.1 christos 53 1.1 christos if ($lib ne $errlib) 54 1.1.1.2 christos { print "$file:$.:$func:$n [${errlib}err]\n"; $bad = 1; next; } 55 1.1 christos 56 1.1 christos $n =~ tr/A-Z/a-z/; 57 1.1 christos if (($n ne $func) && ($errlib ne "SYS")) 58 1.1.1.2 christos { print "$file:$.:$func:$n\n"; $bad = 1; next; } 59 1.1 christos # print "$func:$1\n"; 60 1.1 christos } 61 1.1 christos } 62 1.1 christos close(IN); 63 1.1 christos } 64 1.1 christos 65 1.1.1.2 christos if ($bad && $err_strict) 66 1.1.1.2 christos { 67 1.1.1.2 christos print STDERR "FATAL: error discrepancy\n"; 68 1.1.1.2 christos exit 1; 69 1.1.1.2 christos } 70 1.1.1.2 christos 71