Re: [PATCH 4/7] revert: Allow mixed pick and revert instructions
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Aug 14, 2011, 14:06 UTC
- Message-ID
- <CALkWK0=sggexB0HDN-6LsoLz2RO-ftABTnAYp7q-jVO0oCJu2A@mail.gmail.com>
- In-Reply-To
- <20110814121244.GD18466@elie.gateway.2wire.net>
Hi Jonathan,
Jonathan Nieder writes:
Show 7 quoted lines
> Ramkumar Ramachandra wrote:
>> + int len = strchrnul(p, '\n') - p;
>> + if (len > 255)
>> + len = 255;
>> + return error(_("Unrecognized action: %.*s"), len, p);
>
> What happens if the current line has more than INT_MAX characters?I don't know! I don't think this behavior is defined by the C89 standard, so I'd expect every compiler to do something different. I'd expect to be able to fix it like this:
int len = strchrnul(p, '\n') - p;
if (len > 255 || len - strchrnul(p, '\n') + p != 0)
len = 255;> Maybe it would make sense to factor out a function for this > computation, for brevity and so there is just one place to tweak.
Shouldn't it be part of error() atleast in the long term? I'll write a quick private helper for now.
Thanks.
-- Ram