This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] genmodes: remove misleading use of strncpy
Richard Guenther wrote:
>>> The patch is ok with caching strlen and using memcpy.
>> Like this, I presume:
>> [alternatively, declare and compute m_len on a separate line,
>> ?just before the comparison:
>> ? size_t m_len = strlen (m->name);
>> ?I'd actually prefer that, but don't know if decl-after-stmt is ok here.
> Works for me with ...
>> - ? ? ?if (strlen (m->name) >= sizeof buf)
>> + ? ? ?if ((m_len = strlen (m->name)) >= sizeof buf)
> ... the strlen in a separate stmt like
> m_len = strlen (m->name);
> if (m_len >= sizeof (buf))
Adjusted and committed.