1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +03:00

formatting.c cleanup: Remove unnecessary zeroize macros

Replace with initializer or memset().

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
This commit is contained in:
Peter Eisentraut
2025-10-30 08:18:34 +01:00
parent 38506f55fd
commit 9a1a5dfee8

View File

@@ -439,8 +439,6 @@ typedef struct
const char *abbrev; /* dynamic abbrev */ const char *abbrev; /* dynamic abbrev */
} TmFromChar; } TmFromChar;
#define ZERO_tmfc(_X) memset(_X, 0, sizeof(TmFromChar))
struct fmt_tz /* do_to_timestamp's timezone info output */ struct fmt_tz /* do_to_timestamp's timezone info output */
{ {
bool has_tz; /* was there any TZ/TZH/TZM field? */ bool has_tz; /* was there any TZ/TZH/TZM field? */
@@ -4365,7 +4363,7 @@ do_to_timestamp(const text *date_txt, const text *fmt, Oid collid, bool std,
int *fprec, uint32 *flags, Node *escontext) int *fprec, uint32 *flags, Node *escontext)
{ {
FormatNode *format = NULL; FormatNode *format = NULL;
TmFromChar tmfc; TmFromChar tmfc = {0};
int fmt_len; int fmt_len;
char *date_str; char *date_str;
int fmask; int fmask;
@@ -4376,7 +4374,6 @@ do_to_timestamp(const text *date_txt, const text *fmt, Oid collid, bool std,
date_str = text_to_cstring(date_txt); date_str = text_to_cstring(date_txt);
ZERO_tmfc(&tmfc);
ZERO_tm(tm); ZERO_tm(tm);
*fsec = 0; *fsec = 0;
tz->has_tz = false; tz->has_tz = false;
@@ -4799,19 +4796,6 @@ fill_str(char *str, int c, int max)
return str; 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 */ /* This works the same as DCH_prevent_counter_overflow */
static inline void static inline void
NUM_prevent_counter_overflow(void) NUM_prevent_counter_overflow(void)
@@ -4919,7 +4903,7 @@ NUM_cache_fetch(const char *str)
*/ */
ent = NUM_cache_getnew(str); ent = NUM_cache_getnew(str);
zeroize_NUM(&ent->Num); memset(&ent->Num, 0, sizeof ent->Num);
parse_format(ent->format, str, NUM_keywords, parse_format(ent->format, str, NUM_keywords,
NULL, NUM_index, NUM_FLAG, &ent->Num); NULL, NUM_index, NUM_FLAG, &ent->Num);
@@ -4950,7 +4934,7 @@ NUM_cache(int len, NUMDesc *Num, const text *pars_str, bool *shouldFree)
*shouldFree = true; *shouldFree = true;
zeroize_NUM(Num); memset(Num, 0, sizeof *Num);
parse_format(format, str, NUM_keywords, parse_format(format, str, NUM_keywords,
NULL, NUM_index, NUM_FLAG, Num); NULL, NUM_index, NUM_FLAG, Num);