[PATCH] Babel: Fix pointer arithmetic in subtlv parsing

Ondrej Zajicek santiago at crfreenet.org
Thu Jun 15 22:06:37 CEST 2017


On Thu, Jun 15, 2017 at 08:38:16AM +0200, Martin Mares wrote:
> Hello, world!\n
> 
> >    for (tlv = (void *) hdr + state->current_tlv_endpos;
> > -       tlv < hdr + TLV_LENGTH(hdr);
> > +       (void *) tlv < (void *) hdr + TLV_LENGTH(hdr);
> >         tlv = NEXT_TLV(tlv))
> 
> BTW, is there any reason for doing that pointer arithmetics
> on void pointers instead of char pointers? It looks like
> an unnecessary GCCism.

Hi

Well, it is not only here but already on plenty of other places in BIRD
code. I don't have a strong opinion about pointer arithmetics on void
pointers. I generally avoid it when writing code but otherwise keep it.
It is true that it is GCCism that is simply eliminable, but it is also
supported by Clang and possibly others as it is a natural extension.

In this particular case it does not help, but in other cases it avoids
some uninformative double casts.

Now, when i am looking at this particular case, i realized it could be
replaced by simple: tlv < NEXT_TLV(hdr);

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: santiago at crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20170615/a56ea5e8/attachment.asc>


More information about the Bird-users mailing list