Skip to content

Commit

Permalink
bugfix: fixed clang warnings on "unused variables" in the Ragel gener…
Browse files Browse the repository at this point in the history
…ated source.
  • Loading branch information
agentzh committed Jun 16, 2015
1 parent 029a07b commit 0b57f4e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/ngx_http_xss_util.c
Expand Up @@ -19,10 +19,7 @@

#line 21 "src/ngx_http_xss_util.c"
static const int javascript_start = 1;
static const int javascript_first_final = 6;
static const int javascript_error = 0;

static const int javascript_en_main = 1;


#line 17 "src/ngx_http_xss_util.rl"
Expand Down Expand Up @@ -140,11 +137,7 @@ case 5:
#line 38 "src/ngx_http_xss_util.rl"


if (cs <
#line 145 "src/ngx_http_xss_util.c"
6
#line 40 "src/ngx_http_xss_util.rl"
|| p != pe) {
if (cs < 6 || p != pe) {
return NGX_DECLINED;
}

Expand Down
2 changes: 2 additions & 0 deletions util/build.sh
Expand Up @@ -8,6 +8,8 @@ if [ $? != 0 ]; then
exit 1;
fi

./util/fix-clang-warnings || exit 1

root=`pwd`
home=~
version=$1
Expand Down
46 changes: 46 additions & 0 deletions util/fix-clang-warnings
@@ -0,0 +1,46 @@
#!/usr/bin/env perl

use strict;
use warnings;
use File::Temp 'tempfile';

my $infile = "src/ngx_http_xss_util.c";
my ($out, $outfile) = tempfile();
open my $in, $infile
or die "Cannot open $infile for reading: $!\n";

my $hits = 0;
while (<$in>) {
if (/ \b javascript_ (?: en_main | error | first_final ) \b /x)
{
#warn "HIT!";
$hits++;
next;
}
print $out $_;
}

close $in;
close $out;

if ($hits) {
my $cmd = "cp $outfile $infile";
system($cmd) == 0
or die "Cannot run command \"$cmd\": $!";
}
#die;

__END__
This script is to fix the following clang warnings when using Ragel 6.8/6.9/etc:
rc/ngx_http_xss_util.c:22:18: error: unused variable 'javascript_first_final' [-Werror,-Wunused-const-variable]
static const int javascript_first_final = 6;
^
src/ngx_http_xss_util.c:23:18: error: unused variable 'javascript_error' [-Werror,-Wunused-const-variable]
static const int javascript_error = 0;
^
src/ngx_http_xss_util.c:25:18: error: unused variable 'javascript_en_main' [-Werror,-Wunused-const-variable]
static const int javascript_en_main = 1;
^
3 errors generated.

0 comments on commit 0b57f4e

Please sign in to comment.