Fix possible variable declaration uninitialized (src/backend/utils/adt/varlena.c)

Started by Ranier Vilelaover 4 years ago1 messages
#1Ranier Vilela
ranier.vf@gmail.com
1 attachment(s)

Hi,

This is not a live bug.
I think this is worth fixing, just for the sake of style and code
correctness.
As a bonus, we have a reduced scope and standardized return.

regards,
Ranier Vilela

Attachments:

fix_possible_decl_var_uninitialized_varlena.patchapplication/octet-stream; name=fix_possible_decl_var_uninitialized_varlena.patchDownload
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index d2a11b1b5d..ea9af8e6aa 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -1396,7 +1396,6 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
 {
 	int			haystack_len = state->len1;
 	int			needle_len = state->len2;
-	int			skiptablemask = state->skiptablemask;
 	const char *haystack = state->str1;
 	const char *needle = state->str2;
 	const char *haystack_end = &haystack[haystack_len];
@@ -1420,6 +1419,7 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
 	else
 	{
 		const char *needle_last = &needle[needle_len - 1];
+		int			skiptablemask = state->skiptablemask;
 
 		/* Start at startpos plus the length of the needle */
 		hptr = start_ptr + needle_len - 1;
@@ -1451,7 +1451,7 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
 		}
 	}
 
-	return 0;					/* not found */
+	return NULL;					/* not found */
 }
 
 /*