On Tue, May 05, 2026 at 05:43:18PM +0200, Martin Wilck wrote: > Add a set of simple functions to handle refcounted pointers. > > Signed-off-by: Martin Wilck <[email protected]> > --- > diff --git a/libmpathutil/util.c b/libmpathutil/util.c > index 23a9797..3c623ec 100644 > --- a/libmpathutil/util.c > +++ b/libmpathutil/util.c [...] > +void get_shared_ptr(void *ptr) > +{ > + struct shared_ptr *sp = container_of(ptr, struct shared_ptr, ptr); > + > + if (uatomic_add_return(&sp->refcnt, 1) < 0)
This is fine, but what about using an unsigned refcnt, and checking if this returns 1? It would catch the cases where wrap-around happened, but it would also catch if something incremented a freed pointer. Just a thought. But like I said, this is fine as is, so Reviewed-by: Benjamin Marzinski <[email protected]> > + condlog(0, "%s: refcount overflow", __func__); > +}
