[Mesa-dev] [PATCH v3 1/3] util: Add util_strncpy

Brian Paul brianp at vmware.com
Mon Jul 3 14:38:33 UTC 2017


On 07/03/2017 04:45 AM, Nicolai Hähnle wrote:
> On 03.07.2017 12:44, Nicolai Hähnle wrote:
>> On 03.07.2017 09:43, Gustaw Smolarczyk wrote:
>>> 2017-07-03 6:10 GMT+02:00 Robert Foss <robert.foss at collabora.com>:
>>>> On Sun, 2017-07-02 at 21:06 -0700, Matt Turner wrote:
>>>>> Otherwise known as strlcpy()?
>>>>
>>>> I didn't realize this, a wrapper would be needed for all platformsou
>>>> that don't support it natively.
>>>>
>>>> Do you know which platforms support strlcpy?
>>>>
>>>>
>>>> Rob.
>>>
>>> I think various BSD variants support strlcpy ([1] as an example).
>>
>> I'd suggest to keep the patches mostly the same, but rename
>> util_strncpy to util_strlcpy. That way, the name is aligned with the
>> standard library function that many platforms have, and the code is
>> still fully portable.
>>
>> Keep in mind to adjust also the commit messages when you make the change.
>
> Of course, it would be even nicer to just rename it to strlcpy and add
> some #ifdef magic to figure out which platforms it's needed on.

strlcpy is not available on Windows.  On Linux/glibc, it sounds like 
we'd have to link with the libbsd library.  I think it's simplest to 
just have our own util_strlcpy().

-Brian



More information about the mesa-dev mailing list