[vlc-devel] [PATCH 1/3] vlc_list: helpers for doubly linked lists

Rémi Denis-Courmont remi at remlab.net
Tue Jun 12 21:41:50 CEST 2018


Le tiistaina 12. kesäkuuta 2018, 14.35.02 EEST Romain Vimont a écrit :
> Anyway, my remark about the safe/unsafe version was not about
> performance, but more about passing an additional argument that could be
> avoided in most cases (a foreach with 5 arguments is quite complex to
> use).

Third and fifth arguments define what is actually iterated, and seem 
intrinsically necessary. The first argument defines a variable name and is 
necessary to avoid shadowing.

I cannot find a way to avoid the second (iterator) argument without both 
relying on UB and losing safety against element removal.

The forth argument can be avoided with typeof, but I cannot see a well-defined 
and standard-compliant alternative. Specifically
    (((char *)(&pos->member)) - ((char *)pos))
is constant but undefined if pos is not initialized or not a valid pointer. As 
far as I recall, ubsan is prone to tripping on it.

-- 
Реми Дёни-Курмон
http://www.remlab.net/





More information about the vlc-devel mailing list