Re: pgsql: Add missing string terminator

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Add missing string terminator
Date: 2025-04-30 10:57:56
Message-ID: CAApHDvrg3Gz6kF76Feyc6Dyi9u7iS+vcdQw3VZgGA1+wUc=wRQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Wed, 30 Apr 2025 at 21:36, Daniel Gustafsson
<dgustafsson(at)postgresql(dot)org> wrote:
> Add missing string terminator

A possible minor niggle. Would memcpy not be a more suitable function
for this? It's just there've been a few efforts in the past to try
and minimise the usage of strncpy(). There should really just be a
small handful of cases where the strange behaviour of that function is
needed. I don't think this is one of those cases.

Maybe something like the following would suit better?

#define REMAINING_TOTALS "Remaining Totals"
num_individual_stats = context_id + 1;
meminfo[max_stats - 1].name = dsa_allocate(MemoryStatsDsaArea,
sizeof(REMAINING_TOTALS));
nameptr = dsa_get_address(MemoryStatsDsaArea, meminfo[max_stats - 1].name);
memcpy(nameptr, REMAINING_TOTALS, sizeof(REMAINING_TOTALS));

David

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-04-30 11:27:18 Re: pgsql: Add missing string terminator
Previous Message Daniel Gustafsson 2025-04-30 09:36:04 pgsql: Typo and doc fixups for memory context reporting