]> granicus.if.org Git - postgresql/commitdiff
Silence assorted "variable may be used uninitialized" warnings.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 14 Feb 2018 21:06:49 +0000 (16:06 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 14 Feb 2018 21:06:49 +0000 (16:06 -0500)
All of these are false positives, but in each case a fair amount of
analysis is needed to see that, and it's not too surprising that not all
compilers are smart enough.  (In particular, in the logtape.c case, a
compiler lacking the knowledge provided by the Assert would almost surely
complain, so that this warning will be seen in any non-assert build.)

Some of these are of long standing while others are pretty recent,
but it only seems worth fixing them in HEAD.

Jaime Casanova, tweaked a bit by me

Discussion: https://postgr.es/m/CAJGNTeMcYAMJdPAom52dppLMtF-UnEZi0dooj==75OEv1EoBZA@mail.gmail.com

src/backend/access/transam/xloginsert.c
src/backend/catalog/objectaddress.c
src/backend/utils/sort/logtape.c
src/bin/pgbench/pgbench.c

index de869e00ffe65ce13c50b1bae25a84859110805c..5bea073a2b7e8af341a016d6e5c8b084efe0fbcc 100644 (file)
@@ -584,7 +584,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
                if (include_image)
                {
                        Page            page = regbuf->page;
-                       uint16          compressed_len;
+                       uint16          compressed_len = 0;
 
                        /*
                         * The page needs to be backed up, so calculate its hole length
index b4c2467710955aa045354a5a771cb41693b852f2..80f561df1c1969b911771d97d0d497ce7eec2a9e 100644 (file)
@@ -1593,6 +1593,8 @@ get_object_address_opf_member(ObjectType objtype,
        famaddr = get_object_address_opcf(OBJECT_OPFAMILY, copy, false);
 
        /* find out left/right type names and OIDs */
+       typenames[0] = typenames[1] = NULL;
+       typeoids[0] = typeoids[1] = InvalidOid;
        i = 0;
        foreach(cell, lsecond(object))
        {
index 66bfcced8d7ee50c5b2b0e3530931c49b7ef3654..d6794bf3de1ee38f7fc954c21b9a9030e5bfd9f8 100644 (file)
@@ -411,7 +411,7 @@ ltsConcatWorkerTapes(LogicalTapeSet *lts, TapeShare *shared,
                                         SharedFileSet *fileset)
 {
        LogicalTape *lt = NULL;
-       long            tapeblocks;
+       long            tapeblocks = 0L;
        long            nphysicalblocks = 0L;
        int                     i;
 
index 31ea6ca06e0e98159d2b6cc3677b4853654f328f..d4209421f50afd145ffb61ddc16937ed719224d3 100644 (file)
@@ -1495,6 +1495,7 @@ coerceToBool(PgBenchValue *pval, bool *bval)
        else /* NULL, INT or DOUBLE */
        {
                fprintf(stderr, "cannot coerce %s to boolean\n", valueTypeName(pval));
+               *bval = false;                  /* suppress uninitialized-variable warnings */
                return false;
        }
 }
@@ -1725,9 +1726,9 @@ evalLazyFunc(TState *thread, CState *st,
  * which do not require lazy evaluation.
  */
 static bool
-evalStandardFunc(
-       TState *thread, CState *st,
-       PgBenchFunction func, PgBenchExprLink *args, PgBenchValue *retval)
+evalStandardFunc(TState *thread, CState *st,
+                                PgBenchFunction func, PgBenchExprLink *args,
+                                PgBenchValue *retval)
 {
        /* evaluate all function arguments */
        int                             nargs = 0;