[Okular-devel] unitialised value (CID:5881)

Brad Hards bradh at frogmouth.net
Sat Jan 17 11:46:06 CET 2009


Coverity says that there is a path through doFilePrint that can result in 
returning an uninitialised value (in this case, ret).

(I agree: look at the path through line 83:
	            if ( res ) ret = 0;
If res is not true, then ret won't be initialised.)

See run 183 for this one.

We could just turn that into 
if (res) {
	ret = 0;
} else {
	ret = -1;
}
but it seems cleaner to just initialise it in the first place. See below.

I'm just not sure what the right initialisation value should be. Ideas?

Brad

--- core/fileprinter.cpp        (revision 912249)
+++ core/fileprinter.cpp        (working copy)
@@ -66,7 +66,7 @@

     QString exe;
     QStringList argList;
-    int ret;
+    int ret = -1;

     // Print to File if a filename set, assumes there must be only 1 file
     if ( !printer.outputFileName().isEmpty() ) {


More information about the Okular-devel mailing list