diff options
| author | Peter Eisentraut <peter@eisentraut.org> | 2022-07-16 08:42:15 +0200 |
|---|---|---|
| committer | Peter Eisentraut <peter@eisentraut.org> | 2022-07-16 08:50:49 +0200 |
| commit | 9fd45870c1436b477264c0c82eb195df52bc0919 (patch) | |
| tree | 10a09724c0bcffa8f58f262e50c3260cde484446 /contrib/pg_walinspect/pg_walinspect.c | |
| parent | c94ae9d827a360d74da6a304692d34a4dc8b6445 (diff) | |
Replace many MemSet calls with struct initialization
This replaces all MemSet() calls with struct initialization where that
is easily and obviously possible. (For example, some cases have to
worry about padding bits, so I left those.)
(The same could be done with appropriate memset() calls, but this
patch is part of an effort to phase out MemSet(), so it doesn't touch
memset() calls.)
Reviewed-by: Ranier Vilela <ranier.vf@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/9847b13c-b785-f4e2-75c3-12ec77a3b05c@enterprisedb.com
Diffstat (limited to 'contrib/pg_walinspect/pg_walinspect.c')
| -rw-r--r-- | contrib/pg_walinspect/pg_walinspect.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c index a082dfb3310..90817876347 100644 --- a/contrib/pg_walinspect/pg_walinspect.c +++ b/contrib/pg_walinspect/pg_walinspect.c @@ -229,8 +229,8 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS) { #define PG_GET_WAL_RECORD_INFO_COLS 11 Datum result; - Datum values[PG_GET_WAL_RECORD_INFO_COLS]; - bool nulls[PG_GET_WAL_RECORD_INFO_COLS]; + Datum values[PG_GET_WAL_RECORD_INFO_COLS] = {0}; + bool nulls[PG_GET_WAL_RECORD_INFO_COLS] = {0}; XLogRecPtr lsn; XLogRecPtr curr_lsn; XLogRecPtr first_record; @@ -266,9 +266,6 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS) errmsg("could not read WAL at %X/%X", LSN_FORMAT_ARGS(first_record)))); - MemSet(values, 0, sizeof(values)); - MemSet(nulls, 0, sizeof(nulls)); - GetWALRecordInfo(xlogreader, first_record, values, nulls, PG_GET_WAL_RECORD_INFO_COLS); @@ -334,8 +331,8 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn, XLogRecPtr first_record; XLogReaderState *xlogreader; ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; - Datum values[PG_GET_WAL_RECORDS_INFO_COLS]; - bool nulls[PG_GET_WAL_RECORDS_INFO_COLS]; + Datum values[PG_GET_WAL_RECORDS_INFO_COLS] = {0}; + bool nulls[PG_GET_WAL_RECORDS_INFO_COLS] = {0}; SetSingleFuncCall(fcinfo, 0); @@ -343,9 +340,6 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn, Assert(xlogreader); - MemSet(values, 0, sizeof(values)); - MemSet(nulls, 0, sizeof(nulls)); - while (ReadNextXLogRecord(xlogreader, first_record) && xlogreader->EndRecPtr <= end_lsn) { @@ -556,17 +550,15 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn, #define PG_GET_WAL_STATS_COLS 9 XLogRecPtr first_record; XLogReaderState *xlogreader; - XLogStats stats; + XLogStats stats = {0}; ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; - Datum values[PG_GET_WAL_STATS_COLS]; - bool nulls[PG_GET_WAL_STATS_COLS]; + Datum values[PG_GET_WAL_STATS_COLS] = {0}; + bool nulls[PG_GET_WAL_STATS_COLS] = {0}; SetSingleFuncCall(fcinfo, 0); xlogreader = InitXLogReaderState(start_lsn, &first_record); - MemSet(&stats, 0, sizeof(stats)); - while (ReadNextXLogRecord(xlogreader, first_record) && xlogreader->EndRecPtr <= end_lsn) { @@ -578,9 +570,6 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn, pfree(xlogreader->private_data); XLogReaderFree(xlogreader); - MemSet(values, 0, sizeof(values)); - MemSet(nulls, 0, sizeof(nulls)); - GetXLogSummaryStats(&stats, rsinfo, values, nulls, PG_GET_WAL_STATS_COLS, stats_per_record); |
