[vlc-devel] [PATCH] atomic: prevent overflow
Rémi Denis-Courmont
remi at remlab.net
Mon Feb 24 09:55:18 CET 2020
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;
> }
>--
>2.17.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200224/3069e8cf/attachment.html>
More information about the vlc-devel
mailing list