Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a725f7

Browse files
committed
Silence assorted "variable may be used uninitialized" warnings.
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
1 parent 0c62356 commit 9a725f7

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/backend/access/transam/xloginsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
584584
if (include_image)
585585
{
586586
Page page = regbuf->page;
587-
uint16 compressed_len;
587+
uint16 compressed_len = 0;
588588

589589
/*
590590
* The page needs to be backed up, so calculate its hole length

src/backend/catalog/objectaddress.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,8 @@ get_object_address_opf_member(ObjectType objtype,
15931593
famaddr = get_object_address_opcf(OBJECT_OPFAMILY, copy, false);
15941594

15951595
/* find out left/right type names and OIDs */
1596+
typenames[0] = typenames[1] = NULL;
1597+
typeoids[0] = typeoids[1] = InvalidOid;
15961598
i = 0;
15971599
foreach(cell, lsecond(object))
15981600
{

src/backend/utils/sort/logtape.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ ltsConcatWorkerTapes(LogicalTapeSet *lts, TapeShare *shared,
411411
SharedFileSet *fileset)
412412
{
413413
LogicalTape *lt = NULL;
414-
long tapeblocks;
414+
long tapeblocks = 0L;
415415
long nphysicalblocks = 0L;
416416
int i;
417417

src/bin/pgbench/pgbench.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,7 @@ coerceToBool(PgBenchValue *pval, bool *bval)
14951495
else /* NULL, INT or DOUBLE */
14961496
{
14971497
fprintf(stderr, "cannot coerce %s to boolean\n", valueTypeName(pval));
1498+
*bval = false; /* suppress uninitialized-variable warnings */
14981499
return false;
14991500
}
15001501
}
@@ -1725,9 +1726,9 @@ evalLazyFunc(TState *thread, CState *st,
17251726
* which do not require lazy evaluation.
17261727
*/
17271728
static bool
1728-
evalStandardFunc(
1729-
TState *thread, CState *st,
1730-
PgBenchFunction func, PgBenchExprLink *args, PgBenchValue *retval)
1729+
evalStandardFunc(TState *thread, CState *st,
1730+
PgBenchFunction func, PgBenchExprLink *args,
1731+
PgBenchValue *retval)
17311732
{
17321733
/* evaluate all function arguments */
17331734
int nargs = 0;

0 commit comments

Comments
 (0)