René Scharfe writes:
> Actually I didn't sign-off on purpose originally. But OK, let's keep
> the version below. I just feel strangely sad seeing that concise magic
> go. Nevermind.
I actually share the sadness, too, but let's be stupid and obvious
here.
Thanks.
>
> Signed-off-by: Rene Scha
Am 25.10.2016 um 20:28 schrieb Junio C Hamano:
Jeff King writes:
On Mon, Oct 24, 2016 at 04:53:50PM -0700, Junio C Hamano wrote:
So how about this? It gets rid of magic number 3 and works for array
size that's not a power of two. And as a nice side effect it can't
trigger a signed overflow
Jeff King writes:
>> diff --git a/path.c b/path.c
>> index fe3c4d96c6..9bfaeda207 100644
>> --- a/path.c
>> +++ b/path.c
>> @@ -24,7 +24,8 @@ static struct strbuf *get_pathname(void)
>> STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
>> };
>> static int index;
>> -st
On Tue, Oct 25, 2016 at 11:28:40AM -0700, Junio C Hamano wrote:
> OK, here is what I'll queue then.
> I assumed that René wants to sign it off ;-).
>
> -- >8 --
> From: René Scharfe
> Date: Sun, 23 Oct 2016 19:57:30 +0200
> Subject: [PATCH] hex: make wraparound of the index into ring-buffer expl
Jeff King writes:
> On Mon, Oct 24, 2016 at 04:53:50PM -0700, Junio C Hamano wrote:
>
>> > So how about this? It gets rid of magic number 3 and works for array
>> > size that's not a power of two. And as a nice side effect it can't
>> > trigger a signed overflow anymore.
>>
>> Looks good to me
On Mon, Oct 24, 2016 at 04:53:50PM -0700, Junio C Hamano wrote:
> > So how about this? It gets rid of magic number 3 and works for array
> > size that's not a power of two. And as a nice side effect it can't
> > trigger a signed overflow anymore.
>
> Looks good to me. Peff?
Any of the variant
René Scharfe writes:
> Am 24.10.2016 um 19:27 schrieb Junio C Hamano:
>> Junio C Hamano writes:
>>
I think it would be preferable to just fix it inline in each place.
>>>
>>> Yeah, probably.
>>>
>>> My initial reaction to this was
>>>
>>> char *sha1_to_hex(const unsigned char *sha1)
>>>
Am 24.10.2016 um 19:27 schrieb Junio C Hamano:
> Junio C Hamano writes:
>
>>> I think it would be preferable to just fix it inline in each place.
>>
>> Yeah, probably.
>>
>> My initial reaction to this was
>>
>> char *sha1_to_hex(const unsigned char *sha1)
>> {
>> -static int bufno;
>> +
Junio C Hamano writes:
>> I think it would be preferable to just fix it inline in each place.
>
> Yeah, probably.
>
> My initial reaction to this was
>
> char *sha1_to_hex(const unsigned char *sha1)
> {
> - static int bufno;
> + static unsigned int bufno;
> static char hexbuffer[4
Jeff King writes:
>> > You could also write the second line like:
>> >
>> > bufno %= ARRAY_SIZE(hexbuffer);
>> >
>> > which is less magical (right now the set of buffers must be a power of
>> > 2). I expect the compiler could turn that into a bitmask itself.
>> ...
>
> I think it would be pre
On Sun, Oct 23, 2016 at 07:57:30PM +0200, René Scharfe wrote:
> > > Hard to trigger, but probably even harder to diagnose once someone
> > > somehow manages to do it on some uncommon architecture.
> >
> > Indeed. If we are worried about overflow, we would also want to assume
> > that it wraps at
Am 23.10.2016 um 11:11 schrieb Jeff King:
On Sun, Oct 23, 2016 at 11:00:48AM +0200, René Scharfe wrote:
Overflow is defined for unsigned integers, but not for signed ones.
Make the ring buffer index in sha1_to_hex() unsigned to be on the
safe side.
Signed-off-by: Rene Scharfe
---
Hard to trig
On Sun, Oct 23, 2016 at 11:00:48AM +0200, René Scharfe wrote:
> Overflow is defined for unsigned integers, but not for signed ones.
> Make the ring buffer index in sha1_to_hex() unsigned to be on the
> safe side.
>
> Signed-off-by: Rene Scharfe
> ---
> Hard to trigger, but probably even harder t
Overflow is defined for unsigned integers, but not for signed ones.
Make the ring buffer index in sha1_to_hex() unsigned to be on the
safe side.
Signed-off-by: Rene Scharfe
---
Hard to trigger, but probably even harder to diagnose once someone
somehow manages to do it on some uncommon architectur
14 matches
Mail list logo