[PATCH v2] Add a trie to map quickly from address range to compilation unit.
Alan Modra
amodra@gmail.com
Fri Apr 8 12:10:10 GMT 2022
On Fri, Apr 08, 2022 at 12:43:14PM +0200, Jan Beulich wrote:
> On 08.04.2022 12:38, Alan Modra wrote:
> > On Fri, Apr 08, 2022 at 10:05:55AM +0200, Jan Beulich via Binutils wrote:
> >> On 04.04.2022 09:32, Steinar H. Gunderson via Binutils wrote:
> >>> + if (leaf != NULL)
> >>> + leaf->head.num_room_in_leaf = TRIE_LEAF_SIZE;
> >>> + return (struct trie_node *) leaf;
> >>
> >> Furthermore, with casts being somewhat risky in general (and there not
> >> being more fine-grained C++-like casts in C), I think it would be better
> >> to use &leaf->head in such cases.
> >
> > Except that if leaf can be NULL then &leaf->head is undefined
> > according to the C standard. ubsan will complain. I dislike casts
> > too, but this is one annoying case where C requires one.
>
> if (leaf == NULL)
> return NULL;
> leaf->head.num_room_in_leaf = TRIE_LEAF_SIZE;
> return &leaf->head;
Yes, that's fine.
return leaf ? &leaf->head : NULL;
works too but I find it a little awkward.
BTW, a cast to the proper type is no better really than
return (void *) leaf;
Minimal typing and makes C++ heads explode. :-)
I'm not trying to lay down style rules here. Anything that avoids
ubsan errors is OK as far as I'm concerned.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list