This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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))

Thanks.
Adjusted and committed.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]