glusterfs
1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5
6my @ignore_labels = qw (TODO retry fetch_data again try_again sp_state_read_proghdr redo disabled_loop fd_alloc_try_again);
7my @ignore_files = qw (y.tab.c lex.c);
8my @c_files;
9my $line;
10my @labels;
11my $in_comments;
12
13{
14local $" = "|";
15my $cmd = "find . -type f -name '*.c' | grep -vE '(@ignore_files)'";
16@c_files = `$cmd`;
17}
18
19foreach my $file (@c_files) {
20chomp ($file);
21open FD, $file or die ("Failed to read file $file: $!");
22@labels = ();
23$in_comments = 0;
24while ($line = <FD>) {
25chomp ($line);
26
27next if $line =~ /^\s*(#|\/\/)/;
28$in_comments = 1 if ($line =~ /\/\*/);
29$in_comments = 0 if ($line =~ /\*\//);
30
31next if $in_comments;
32if ($line =~ /^\s*(([a-zA-Z]|_)\w*)\s*:/) {
33push (@labels, $1) unless grep (/$1/, @ignore_labels);
34}
35@labels = () if $line =~ /^}/;
36
37next unless @labels;
38if ($line =~ /^\s*goto\s*(\w+)/) {
39print "$file:$.: $line\n" if grep /^$1$/, @labels;
40}
41}
42
43close FD;
44}
45
46