[PATCH] genmodes: don't truncate a mode name of length >= 7

Jim Meyering jim@meyering.net
Fri Apr 20 15:39:00 GMT 2012


Richard Guenther wrote:
> On Thu, Apr 19, 2012 at 10:35 PM, Jim Meyering <jim@meyering.net> wrote:
>> Richard Guenther wrote:
>>> Sure, my point was that the
>>>
>>>       if (strlen (m->name) >= sizeof buf)
>>>         {
>>>           error ("%s:%d:mode name \"%s\" is too long",
>>>                  m->file, m->line, m->name);
>>>           continue;
>>>         }
>>>
>>> check does not account for the (conditional) prepending of 'C' and the
>>> snprintf would silently discard the last character of the name.
>>
>> Here's a patch for that.  (passes make bootstrap)
>> Incidentally it removes the name-length limitation of 7 and it hoists
>> the xmalloc, which induces the single added free-before-continue.
>> There was some clean-up along the way: "q" was easy to eliminate, and
>> I pulled the two identical snprintf calls out of the "if" block and
>> replaced them with the buf[0] assignment and memcpy.
>
> Ok.

Thanks for the review.  Committed.



More information about the Gcc-patches mailing list