Skip to content

Commit cd6c45c

Browse files
committed
Suppress maybe-uninitialized compiler warnings.
Previously some compilers were thinking that the variables that 57aa5b2 added maybe-uninitialized. Spotted by Andres Freund
1 parent 5ff6839 commit cd6c45c

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/backend/access/transam/xloginsert.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,9 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
491491
bool needs_data;
492492
XLogRecordBlockHeader bkpb;
493493
XLogRecordBlockImageHeader bimg;
494-
XLogRecordBlockCompressHeader cbimg;
494+
XLogRecordBlockCompressHeader cbimg = {0};
495495
bool samerel;
496496
bool is_compressed = false;
497-
uint16 hole_length;
498-
uint16 hole_offset;
499497

500498
if (!regbuf->in_use)
501499
continue;
@@ -558,21 +556,21 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
558556
upper > lower &&
559557
upper <= BLCKSZ)
560558
{
561-
hole_offset = lower;
562-
hole_length = upper - lower;
559+
bimg.hole_offset = lower;
560+
cbimg.hole_length = upper - lower;
563561
}
564562
else
565563
{
566564
/* No "hole" to compress out */
567-
hole_offset = 0;
568-
hole_length = 0;
565+
bimg.hole_offset = 0;
566+
cbimg.hole_length = 0;
569567
}
570568
}
571569
else
572570
{
573571
/* Not a standard page header, don't try to eliminate "hole" */
574-
hole_offset = 0;
575-
hole_length = 0;
572+
bimg.hole_offset = 0;
573+
cbimg.hole_length = 0;
576574
}
577575

578576
/*
@@ -581,7 +579,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
581579
if (wal_compression)
582580
{
583581
is_compressed =
584-
XLogCompressBackupBlock(page, hole_offset, hole_length,
582+
XLogCompressBackupBlock(page, bimg.hole_offset,
583+
cbimg.hole_length,
585584
regbuf->compressed_page,
586585
&compressed_len);
587586
}
@@ -595,25 +594,21 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
595594
rdt_datas_last->next = &regbuf->bkp_rdatas[0];
596595
rdt_datas_last = rdt_datas_last->next;
597596

598-
bimg.bimg_info = (hole_length == 0) ? 0 : BKPIMAGE_HAS_HOLE;
597+
bimg.bimg_info = (cbimg.hole_length == 0) ? 0 : BKPIMAGE_HAS_HOLE;
599598

600599
if (is_compressed)
601600
{
602601
bimg.length = compressed_len;
603-
bimg.hole_offset = hole_offset;
604602
bimg.bimg_info |= BKPIMAGE_IS_COMPRESSED;
605-
if (hole_length != 0)
606-
cbimg.hole_length = hole_length;
607603

608604
rdt_datas_last->data = regbuf->compressed_page;
609605
rdt_datas_last->len = compressed_len;
610606
}
611607
else
612608
{
613-
bimg.length = BLCKSZ - hole_length;
614-
bimg.hole_offset = hole_offset;
609+
bimg.length = BLCKSZ - cbimg.hole_length;
615610

616-
if (hole_length == 0)
611+
if (cbimg.hole_length == 0)
617612
{
618613
rdt_datas_last->data = page;
619614
rdt_datas_last->len = BLCKSZ;
@@ -622,13 +617,15 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
622617
{
623618
/* must skip the hole */
624619
rdt_datas_last->data = page;
625-
rdt_datas_last->len = hole_offset;
620+
rdt_datas_last->len = bimg.hole_offset;
626621

627622
rdt_datas_last->next = &regbuf->bkp_rdatas[1];
628623
rdt_datas_last = rdt_datas_last->next;
629624

630-
rdt_datas_last->data = page + (hole_offset + hole_length);
631-
rdt_datas_last->len = BLCKSZ - (hole_offset + hole_length);
625+
rdt_datas_last->data =
626+
page + (bimg.hole_offset + cbimg.hole_length);
627+
rdt_datas_last->len =
628+
BLCKSZ - (bimg.hole_offset + cbimg.hole_length);
632629
}
633630
}
634631

@@ -665,7 +662,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
665662
{
666663
memcpy(scratch, &bimg, SizeOfXLogRecordBlockImageHeader);
667664
scratch += SizeOfXLogRecordBlockImageHeader;
668-
if (hole_length != 0 && is_compressed)
665+
if (cbimg.hole_length != 0 && is_compressed)
669666
{
670667
memcpy(scratch, &cbimg,
671668
SizeOfXLogRecordBlockCompressHeader);

0 commit comments

Comments
 (0)