[vlc-devel] [PATCH] atomic: prevent overflow
Steve Lhomme
robux4 at ycbcr.xyz
Mon Mar 2 14:53:30 CET 2020
ping ?
On 2020-02-24 9:55, Rémi Denis-Courmont wrote:
> Will merge later if there are no objections.
>
> Le 24 février 2020 10:33:35 GMT+02:00, quentin.chateau at deepskycorp.com a
> écrit :
>
> From: Quentin Chateau <quentin.chateau at deepskycorp.com>
> ------------------------------------------------------------------------
> include/vlc_atomic.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/vlc_atomic.h b/include/vlc_atomic.h
> index e2d4fe5360..625738849a 100644
> --- a/include/vlc_atomic.h
> +++ b/include/vlc_atomic.h
> @@ -60,7 +60,7 @@ static inline void vlc_atomic_store_float(vlc_atomic_float *atom, float f)
> }
>
> typedef struct vlc_atomic_rc_t {
> - atomic_uint refs;
> + atomic_uintptr_t refs;
> } vlc_atomic_rc_t;
>
> /** Init the RC to 1 */
> @@ -72,7 +72,7 @@ static inline void vlc_atomic_rc_init(vlc_atomic_rc_t *rc)
> /** Increment the RC */
> static inline void vlc_atomic_rc_inc(vlc_atomic_rc_t *rc)
> {
> - unsigned prev = atomic_fetch_add_explicit(&rc->refs, 1, memory_order_relaxed);
> + uintptr_t prev = atomic_fetch_add_explicit(&rc->refs, 1, memory_order_relaxed);
> vlc_assert(prev);
> VLC_UNUSED(prev);
> }
> @@ -80,7 +80,7 @@ static inline void vlc_atomic_rc_inc(vlc_atomic_rc_t *rc)
> /** Decrement the RC and return true if it reaches 0 */
> static inline bool vlc_atomic_rc_dec(vlc_atomic_rc_t *rc)
> {
> - unsigned prev = atomic_fetch_sub_explicit(&rc->refs, 1, memory_order_acq_rel);
> + uintptr_t prev = atomic_fetch_sub_explicit(&rc->refs, 1, memory_order_acq_rel);
> vlc_assert(prev);
> return prev == 1;
> }
>
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser
> ma brièveté.
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list