Re: [PATCH] tag: avoid NULL pointer arithmetic

2017-10-03 Thread René Scharfe
Am 03.10.2017 um 12:22 schrieb SZEDER Gábor: >> lookup_blob() etc. can return NULL if the referenced object isn't of the >> expected type. In theory it's wrong to reference the object member in >> that case. In practice it's OK because it's located at offset 0 for all >> types, so the pointer ari

Re: [PATCH] tag: avoid NULL pointer arithmetic

2017-10-03 Thread SZEDER Gábor
> lookup_blob() etc. can return NULL if the referenced object isn't of the > expected type. In theory it's wrong to reference the object member in > that case. In practice it's OK because it's located at offset 0 for all > types, so the pointer arithmetic (NULL + 0) is optimized out by the > comp

Re: [PATCH] tag: avoid NULL pointer arithmetic

2017-10-02 Thread Jeff King
On Mon, Oct 02, 2017 at 03:06:57PM +0200, René Scharfe wrote: > >> Avoid the ASan error by casting the results of the lookup functions to > >> struct object pointers. That works fine with NULL pointers as well. We > >> already rely on the object member being first in all object types in > >> oth

Re: [PATCH] tag: avoid NULL pointer arithmetic

2017-10-02 Thread René Scharfe
Am 02.10.2017 um 07:08 schrieb Jeff King: > On Sun, Oct 01, 2017 at 04:45:13PM +0200, René Scharfe wrote: > >> lookup_blob() etc. can return NULL if the referenced object isn't of the >> expected type. In theory it's wrong to reference the object member in >> that case. In practice it's OK becau

Re: [PATCH] tag: avoid NULL pointer arithmetic

2017-10-01 Thread Jeff King
On Sun, Oct 01, 2017 at 04:45:13PM +0200, René Scharfe wrote: > lookup_blob() etc. can return NULL if the referenced object isn't of the > expected type. In theory it's wrong to reference the object member in > that case. In practice it's OK because it's located at offset 0 for all > types, so t

Re: [PATCH] tag: avoid NULL pointer arithmetic

2017-10-01 Thread Junio C Hamano
René Scharfe writes: > lookup_blob() etc. can return NULL if the referenced object isn't of the > expected type. In theory it's wrong to reference the object member in > that case. In practice it's OK because it's located at offset 0 for all > types, so the pointer arithmetic (NULL + 0) is opti

[PATCH] tag: avoid NULL pointer arithmetic

2017-10-01 Thread René Scharfe
lookup_blob() etc. can return NULL if the referenced object isn't of the expected type. In theory it's wrong to reference the object member in that case. In practice it's OK because it's located at offset 0 for all types, so the pointer arithmetic (NULL + 0) is optimized out by the compiler. The