Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Date: 2022-07-11 13:26:16
Message-ID: 74fa8809-0acf-b5da-7098-669e9807a5ac@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 07.07.22 13:16, Alvaro Herrera wrote:
> On 2022-Jul-07, Peter Eisentraut wrote:
>
>> diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
>> index 4445a86aee..79b23fa7d7 100644
>> --- a/src/bin/pg_basebackup/pg_basebackup.c
>> +++ b/src/bin/pg_basebackup/pg_basebackup.c
>
>> @@ -1952,7 +1948,6 @@ BaseBackup(char *compression_algorithm, char *compression_detail,
>> else
>> starttli = latesttli;
>> PQclear(res);
>> - MemSet(xlogend, 0, sizeof(xlogend));
>>
>> if (verbose && includewal != NO_WAL)
>> pg_log_info("write-ahead log start point: %s on timeline %u",
>
> You removed the MemSet here, but there's no corresponding
> initialization.

Maybe that was an oversight by me, but it seems to me that that
initialization was useless anyway, since xlogend is later
unconditionally overwritten anyway.

>> diff --git a/src/port/snprintf.c b/src/port/snprintf.c
>> index abb1c59770..e646b0e642 100644
>> --- a/src/port/snprintf.c
>> +++ b/src/port/snprintf.c
>> @@ -756,12 +756,9 @@ find_arguments(const char *format, va_list args,
>> int longflag;
>> int fmtpos;
>> int i;
>> - int last_dollar;
>> - PrintfArgType argtypes[PG_NL_ARGMAX + 1];
>> -
>> /* Initialize to "no dollar arguments known" */
>> - last_dollar = 0;
>> - MemSet(argtypes, 0, sizeof(argtypes));
>> + int last_dollar = 0;
>> + PrintfArgType argtypes[PG_NL_ARGMAX + 1] = {0};
>
> pgindent will insert a blank line before the comment, which I personally
> find quite ugly (because it splits the block of declarations).

Yeah. I think I can convert that to an end-of-line comment instead.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2022-07-11 13:54:19 Re: [BUG] Logical replication failure "ERROR: could not map filenode "base/13237/442428" to relation OID" with catalog modifying txns
Previous Message Maxim Orlov 2022-07-11 13:19:39 Re: Add 64-bit XIDs into PostgreSQL 15