Revision: 1417
http://vcs.pcre.org/viewvc?view=rev&revision=1417
Author: ph10
Date: 2013-12-24 18:03:06 +0000 (Tue, 24 Dec 2013)
Log Message:
-----------
Get rid of some unitialized variable compiler warnings.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/maint/ManyConfigTests
code/trunk/pcre_compile.c
code/trunk/pcre_exec.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2013-12-23 13:42:19 UTC (rev 1416)
+++ code/trunk/ChangeLog 2013-12-24 18:03:06 UTC (rev 1417)
@@ -11,6 +11,9 @@
2. The auto-possessification of character sets were improved: a normal
and an extended character set can be compared now. Furthermore
the JIT compiler optimizes more character set checks.
+
+3. Got rid of some compiler warnings for potentially uninitialized variables
+ that show up only when compiled with -O2.
Version 8.34 15-December-2013
Modified: code/trunk/maint/ManyConfigTests
===================================================================
--- code/trunk/maint/ManyConfigTests 2013-12-23 13:42:19 UTC (rev 1416)
+++ code/trunk/maint/ManyConfigTests 2013-12-24 18:03:06 UTC (rev 1417)
@@ -23,16 +23,20 @@
tmp=/tmp/pcretesting
-# Don't bother with compiler optimization; it just slows down compilation a lot
-# (and running the tests themselves is quick).
+# Don't bother with compiler optimization for most tests; it just slows down
+# compilation a lot (and running the tests themselves is quick). However, a
+# few specific tests turn optimization on, because it can provoke some compiler
+# warnings.
CFLAGS="-g -O0"
CXXFLAGS="$CFLAGS"
+ISGCC="no"
# If the compiler is gcc, add a lot of warning switches.
cc --version >zzz 2>/dev/null
if [ $? -eq 0 ] && grep GCC zzz >/dev/null; then
+ ISGCC="yes"
CFLAGS="$CFLAGS -Wall"
CFLAGS="$CFLAGS -Wno-overlength-strings"
CFLAGS="$CFLAGS -Wpointer-arith"
@@ -159,25 +163,38 @@
}
+# Update the total count whenever a new test is added; it is used to show
+# progess as each test is run.
+
+testtotal=42
+testcount=0
+
# This set of tests builds PCRE and runs the tests with a variety of configure
-# options, in the current (source) directory. The first (empty) configuration
-# builds with all the default settings. As well as testing that these options
-# work, we use --disable-shared or --disable-static after the first test (which
-# builds both) to save a bit of time by building only one version of the
-# library for the subsequent tests.
+# options, in the current (source) directory. The empty configuration builds
+# with all the default settings. As well as testing that these options work, we
+# use --disable-shared or --disable-static after the default test (which builds
+# both) to save a bit of time by building only one version of the library for
+# the subsequent tests.
valgrind=
cvalgrind=
withvalgrind=
+srcdir=.
+export srcdir
-# Update the total count whenever a new test is added; it is used to show
-# progess as each test is run.
+# If gcc is in use, run a maximally configured test with -O2, because that can
+# throw up warnings that are not detected with -O0.
-testtotal=41
-testcount=0
+if [ "$ISGCC" = "yes" ]; then
+ echo "Maximally configured test with -O2"
+ SAVECLFAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -O2"
+ opts="--disable-shared --enable-unicode-properties --enable-jit --enable-pcre16 --enable-pcre32"
+ runtest
+ CFLAGS="$SAVECFLAGS"
+fi
-echo "Tests in the current directory"
-srcdir=.
+echo "General tests in the current directory"
for opts in \
"" \
"--enable-utf8 --disable-static" \
Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c 2013-12-23 13:42:19 UTC (rev 1416)
+++ code/trunk/pcre_compile.c 2013-12-24 18:03:06 UTC (rev 1417)
@@ -6611,7 +6611,10 @@
code[1+LINK_SIZE] = OP_CREF;
skipbytes = 1+IMM2_SIZE;
- refsign = -1;
+ refsign = -1; /* => not a number */
+ namelen = -1; /* => not a name; must set to avoid warning */
+ name = NULL; /* Always set to avoid warning */
+ recno = 0; /* Always set to avoid warning */
/* Check for a test for recursion in a named group. */
@@ -6648,7 +6651,6 @@
if (refsign >= 0)
{
- recno = 0;
while (IS_DIGIT(*ptr))
{
recno = recno * 10 + (int)(*ptr - CHAR_0);
Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c 2013-12-23 13:42:19 UTC (rev 1416)
+++ code/trunk/pcre_exec.c 2013-12-24 18:03:06 UTC (rev 1417)
@@ -2691,16 +2691,22 @@
pcre_uchar *slot = md->name_table + GET2(ecode, 1) * md->name_entry_size;
ecode += 1 + 2*IMM2_SIZE;
+ /* Setting the default length first and initializing 'offset' avoids
+ compiler warnings in the REF_REPEAT code. */
+
+ length = (md->jscript_compat)? 0 : -1;
+ offset = 0;
+
while (count-- > 0)
{
offset = GET2(slot, 0) << 1;
- if (offset < offset_top && md->offset_vector[offset] >= 0) break;
+ if (offset < offset_top && md->offset_vector[offset] >= 0)
+ {
+ length = md->offset_vector[offset+1] - md->offset_vector[offset];
+ break;
+ }
slot += md->name_entry_size;
}
- if (count < 0)
- length = (md->jscript_compat)? 0 : -1;
- else
- length = md->offset_vector[offset+1] - md->offset_vector[offset];
}
goto REF_REPEAT;