[vlc-devel] [PATCH 1/3] vlc_list: helpers for doubly linked lists
remi at remlab.net
Wed Jun 13 08:55:08 CEST 2018
Err, it does not help. If I forego removal safety, I can remove it.next. I still need it.head for macro expansion safety (evaluate the head exactly once) and it.current to avoid undefined pointer arithmetic on empty list.
So I still need the iterator.
Le 12 juin 2018 23:06:05 GMT+03:00, Romain Vimont <rom1v at videolabs.io> a écrit :
>On Tue, Jun 12, 2018 at 10:41:50PM +0300, Rémi Denis-Courmont wrote:
>> 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
>> > avoided in most cases (a foreach with 5 arguments is quite complex
>> > use).
>> Third and fifth arguments define what is actually iterated, and seem
>> intrinsically necessary. The first argument defines a variable name
>> necessary to avoid shadowing.
>> I cannot find a way to avoid the second (iterator) argument without
>> relying on UB and losing safety against element removal.
>I agree. But I think that it is very common to iterate over a list
>without removing, so providing an additional macro with one parameter
>less (and one variable declaration less "struct vlc_list_it it;" for
>each caller) could be worth it.
>> The forth argument can be avoided with typeof, but I cannot see a
>> and standard-compliant alternative. Specifically
>> (((char *)(&pos->member)) - ((char *)pos))
>> is constant but undefined if pos is not initialized or not a valid
>> far as I recall, ubsan is prone to tripping on it.
>I cannot see a well-defined+standard-compliant solution either.
>However, it seems that every modern compiler supports typeof() or
>__typeof() or __typeof__():
>Maybe we could #define some vlc_typeof() to use the right name?
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vlc-devel