diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0397d3b68d..102a0490b0 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -206,7 +206,8 @@ av_cold void avcodec_register(AVCodec *codec) avcodec_init(); p = &first_avcodec; codec->next = NULL; - while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec)) + + while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec)) p = &(*p)->next; if (codec->init_static_data) @@ -3191,7 +3192,7 @@ void av_register_hwaccel(AVHWAccel *hwaccel) { AVHWAccel **p = &first_hwaccel; hwaccel->next = NULL; - while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel)) + while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel)) p = &(*p)->next; } diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 14ce55f932..2567ce92c1 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -490,7 +490,7 @@ int avfilter_register(AVFilter *filter) filter->next = NULL; - while(avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter)) + while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter)) f = &(*f)->next; return 0; diff --git a/libavformat/format.c b/libavformat/format.c index ac9100b604..36c0131c12 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -54,7 +54,7 @@ void av_register_input_format(AVInputFormat *format) AVInputFormat **p = &first_iformat; format->next = NULL; - while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) + while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) p = &(*p)->next; } @@ -63,7 +63,7 @@ void av_register_output_format(AVOutputFormat *format) AVOutputFormat **p = &first_oformat; format->next = NULL; - while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) + while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) p = &(*p)->next; }