trval.c:179:32: error: ‘rlen2’ may be used uninitialized in this function

Eray Aslan eray.aslan at caf.com.tr
Tue Feb 7 05:02:34 EST 2012


Compiling krb5-1.10 with gcc and -O3 optimizations results in the following
error (-O2 compiles fine btw):

x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H  -I../../include -I../../include
-I./../../lib/krb5/asn.1 -DKRB5_DEPRECATED=1 -DKRB5_PRIVATE  -O3 -pipe
-march=core2 -I/usr/include/et -fno-strict-aliasing -fno-strict-overflow
-Wall -Wcast-align -Wshadow -Wmissing-prototypes -Wno-format-zero-length
-Woverflow -Wstrict-overflow -Wmissing-format-attribute
-Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses
-Wswitch -Wunused-function -Wunused-label -Wunused-variable
-Wunused-value -Wunknown-pragmas -Wsign-compare -Werror=uninitialized
-Werror=declaration-after-statement -Werror=variadic-macros
-Werror-implicit-function-declaration -pthread -c trval.c
trval.c: In function ‘trval2’:
trval.c:179:32: error: ‘rlen2’ may be used uninitialized in this
function
make[2]: *** [trval.o] Error 1

I did not look what gcc does but initializing rlen2 might be a quicker
(and correct?) fix:

diff --git a/tests/asn.1/trval.c b/tests/asn.1/trval.c
index 780d60c..ffd66ac 100644
--- a/tests/asn.1/trval.c
+++ b/tests/asn.1/trval.c
@@ -176,7 +176,7 @@ int trval2(fp, enc, len, lev, rlen)
     int lev;
     int *rlen;
 {
-    int l, eid, elen, xlen, r, rlen2;
+    int l, eid, elen, xlen, r, rlen2 = 0;
     int rlen_ext = 0;
 
     r = OK;

-- 
Eray Aslan


More information about the Kerberos mailing list