From: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
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 05:57:53 |
Message-ID: | 01a9dd18-1066-f5d8-aab8-d55fd6a74dad@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2020-08-05 17:49, Tom Lane wrote:
> However I do see one remaining nit to pick, in CreateInitDecodingContext:
>
> /* register output plugin name with slot */
> SpinLockAcquire(&slot->mutex);
> - StrNCpy(NameStr(slot->data.plugin), plugin, NAMEDATALEN);
> + namestrcpy(&slot->data.plugin, plugin);
> SpinLockRelease(&slot->mutex);
>
> This is already a pro-forma violation of our rule about "only
> straight-line code inside a spinlock". Now I'm not terribly concerned
> about that right now, and the patch as it stands is only changing things
> cosmetically. But if you modify namestrcpy to do pg_mbcliplen then all
> of a sudden there is a whole lot of code that could get reached within
> the spinlock, and I'm not a bit happy about that prospect.
fixed
> BTW, while we're here I think we ought to change namecpy and namestrcpy
> to return void (no caller checks their results) and drop their checks
> for null-pointer inputs. AFAICS a null pointer would be a caller bug in
> every case, and if it isn't, why is failing to initialize the
> destination an OK outcome? I find the provisions for nulls in namestrcmp
> pretty useless too, although it looks like at least some thought has
> been spent there.
fixed
I removed namecpy() altogether because you can just use struct assignment.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachment | Content-Type | Size |
---|---|---|
v3-0001-Replace-remaining-StrNCpy-by-strlcpy.patch | text/plain | 16.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2020-08-08 06:37:44 | Re: 回复:how to create index concurrently on partitioned table |
Previous Message | Michael Paquier | 2020-08-08 01:44:09 | Re: Creating a function for exposing memory usage of backend process |