Skip to content

Commit d934a05

Browse files
committed
Fix uninitialized-variable warning.
In passing, add an Assert defending the presumption that bytes_left is positive to start with. (I'm not exactly convinced that using an unsigned type was such a bright thing here, but let's at least do this much.)
1 parent aedccb1 commit d934a05

File tree

1 file changed

+4
-2
lines changed
  • src/backend/utils/misc

1 file changed

+4
-2
lines changed

src/backend/utils/misc/guc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8741,9 +8741,10 @@ SerializeGUCState(Size maxsize, char *start_address)
87418741
Size actual_size;
87428742
Size bytes_left;
87438743
int i;
8744-
int i_role;
8744+
int i_role = -1;
87458745

87468746
/* Reserve space for saving the actual size of the guc state */
8747+
Assert(maxsize > sizeof(actual_size));
87478748
curptr = start_address + sizeof(actual_size);
87488749
bytes_left = maxsize - sizeof(actual_size);
87498750

@@ -8759,7 +8760,8 @@ SerializeGUCState(Size maxsize, char *start_address)
87598760
else
87608761
serialize_variable(&curptr, &bytes_left, guc_variables[i]);
87618762
}
8762-
serialize_variable(&curptr, &bytes_left, guc_variables[i_role]);
8763+
if (i_role >= 0)
8764+
serialize_variable(&curptr, &bytes_left, guc_variables[i_role]);
87638765

87648766
/* Store actual size without assuming alignment of start_address. */
87658767
actual_size = maxsize - bytes_left - sizeof(actual_size);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy