Re: Replace remaining StrNCpy() by strlcpy()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Replace remaining StrNCpy() by strlcpy()
Date: 2020-08-08 16:09:22
Message-ID: 2850241.1596902962@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> I removed namecpy() altogether because you can just use struct assignment.

Makes sense, and I notice it was unused anyway.

v3 passes eyeball examination (I didn't bother running tests), with
only one remaining nit: the proposed commit message says

They are equivalent,

which per this thread is incorrect. Somebody might possibly refer to this
commit for guidance in updating third-party code, so I don't think we want
to leave a misleading claim here. Perhaps something like

They are equivalent, except that StrNCpy zero-fills the entire
destination buffer instead of providing just one trailing zero.
For all but a tiny number of callers, that's just overhead rather
than being desirable.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2020-08-08 16:42:59 Re: walsender waiting_for_ping spuriously set
Previous Message Tom Lane 2020-08-08 15:09:14 Re: get rid of distprep?