v1-0008-formatting.c-cleanup-Remove-unnecessary-zeroize-m.patch

text/plain

Filename: v1-0008-formatting.c-cleanup-Remove-unnecessary-zeroize-m.patch
Type: text/plain
Part: 7
Message: formatting.c cleanup

Patch

Format: format-patch
Series: patch v1-0008
Subject: formatting.c cleanup: Remove unnecessary zeroize macros
File+
src/backend/utils/adt/formatting.c 3 19
From 51994d68b4a8cd52f5e3c29152aaffa4471f6f87 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 20 Oct 2025 08:16:03 +0200
Subject: [PATCH v1 08/13] formatting.c cleanup: Remove unnecessary zeroize
 macros

Replace with initializer or memset().
---
 src/backend/utils/adt/formatting.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index e11b01242c0..a1d59ef859c 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -439,8 +439,6 @@ typedef struct
 	const char *abbrev;			/* dynamic abbrev */
 } TmFromChar;
 
-#define ZERO_tmfc(_X) memset(_X, 0, sizeof(TmFromChar))
-
 struct fmt_tz					/* do_to_timestamp's timezone info output */
 {
 	bool		has_tz;			/* was there any TZ/TZH/TZM field? */
@@ -4365,7 +4363,7 @@ do_to_timestamp(text *date_txt, text *fmt, Oid collid, bool std,
 				int *fprec, uint32 *flags, Node *escontext)
 {
 	FormatNode *format = NULL;
-	TmFromChar	tmfc;
+	TmFromChar	tmfc = {0};
 	int			fmt_len;
 	char	   *date_str;
 	int			fmask;
@@ -4376,7 +4374,6 @@ do_to_timestamp(text *date_txt, text *fmt, Oid collid, bool std,
 
 	date_str = text_to_cstring(date_txt);
 
-	ZERO_tmfc(&tmfc);
 	ZERO_tm(tm);
 	*fsec = 0;
 	tz->has_tz = false;
@@ -4799,19 +4796,6 @@ fill_str(char *str, int c, size_t maxlen)
 	return str;
 }
 
-#define zeroize_NUM(_n) \
-do { \
-	(_n)->flag		= 0;	\
-	(_n)->lsign		= 0;	\
-	(_n)->pre		= 0;	\
-	(_n)->post		= 0;	\
-	(_n)->pre_lsign_num = 0;	\
-	(_n)->need_locale	= 0;	\
-	(_n)->multi		= 0;	\
-	(_n)->zero_start	= 0;	\
-	(_n)->zero_end		= 0;	\
-} while(0)
-
 /* This works the same as DCH_prevent_counter_overflow */
 static inline void
 NUM_prevent_counter_overflow(void)
@@ -4919,7 +4903,7 @@ NUM_cache_fetch(const char *str)
 		 */
 		ent = NUM_cache_getnew(str);
 
-		zeroize_NUM(&ent->Num);
+		memset(&ent->Num, 0, sizeof ent->Num);
 
 		parse_format(ent->format, str, NUM_keywords,
 					 NULL, NUM_index, NUM_FLAG, &ent->Num);
@@ -4950,7 +4934,7 @@ NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree)
 
 		*shouldFree = true;
 
-		zeroize_NUM(Num);
+		memset(Num, 0, sizeof *Num);
 
 		parse_format(format, str, NUM_keywords,
 					 NULL, NUM_index, NUM_FLAG, Num);
-- 
2.51.0