pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: David Rowley <dgrowleyml@gmail.com>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Add missing string terminator
Date: Wed, 30 Apr 2025 14:44:41 +0200
Message-ID: <0755ae22-4e04-4c69-b344-8c4db54d6e23@eisentraut.org> (raw)
In-Reply-To: <CAApHDvoRKSrujq5FN8WzncVtTpVL2c_LMs-o=8fjdmqce1pmjQ@mail.gmail.com>
References: <E1uA3rI-000Ibx-19@gemulon.postgresql.org>
	<CAApHDvrg3Gz6kF76Feyc6Dyi9u7iS+vcdQw3VZgGA1+wUc=wRQ@mail.gmail.com>
	<9887D3A8-A74F-4836-BC57-74AC4AE901BB@yesql.se>
	<CAApHDvrEJeCPesmpeS24UAU8vanq9vKYZC6m1kTDFkxQQ2qTiw@mail.gmail.com>
	<CAApHDvoRKSrujq5FN8WzncVtTpVL2c_LMs-o=8fjdmqce1pmjQ@mail.gmail.com>

On 30.04.25 13:56, David Rowley wrote:
> On Wed, 30 Apr 2025 at 23:43, David Rowley <dgrowleyml@gmail.com> wrote:
>> memcpy() would make more sense IMO, since the length is
>> known already. I'm fine with either, however.
> 
> In case you're looking for inspiration on a standard to follow,
> commits such as 586dd5d6a did seem to favour memcpy() when the length
> was known and only use strlcpy() when it wasn't.

It looks like the memcpy() uses in that commit are for cases where we 
don't want/need the null terminator.

I think it's best in general to use str* for strings and mem* for 
not-strings.  That's easier to read and also better for static analyzers 
etc.





view thread (8+ messages)  latest in thread

Message-ID: <0755ae22-4e04-4c69-b344-8c4db54d6e23@eisentraut.org>
Permalink:  ../0755ae22-4e04-4c69-b344-8c4db54d6e23@eisentraut.org/
Also on:    postgresql.org/message-id/0755ae22-4e04-4c69-b344-8c4db54d6e23@eisentraut.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org, dgrowleyml@gmail.com, daniel@yesql.se, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add missing string terminator
  In-Reply-To: <0755ae22-4e04-4c69-b344-8c4db54d6e23@eisentraut.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox