From: Michael Brown Date: Sun, 8 Jul 2007 21:02:45 +0000 (+0100) Subject: Make ref_get() return the reference, for cleaner code. X-Git-Tag: v0.9.3~240^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed20fee0cfc5863b308d22abc17a7dbb4327c90f;p=thirdparty%2Fipxe.git Make ref_get() return the reference, for cleaner code. --- diff --git a/src/core/refcnt.c b/src/core/refcnt.c index 36b7ce22a..30bb6deac 100644 --- a/src/core/refcnt.c +++ b/src/core/refcnt.c @@ -29,18 +29,18 @@ * Increment reference count * * @v refcnt Reference counter, or NULL + * @ret refcnt Reference counter * * If @c refcnt is NULL, no action is taken. */ -void ref_get ( struct refcnt *refcnt ) { +struct refcnt * ref_get ( struct refcnt *refcnt ) { - if ( ! refcnt ) - return; - - refcnt->refcnt++; - - DBGC2 ( refcnt, "REFCNT %p incremented to %d\n", - refcnt, refcnt->refcnt ); + if ( refcnt ) { + refcnt->refcnt++; + DBGC2 ( refcnt, "REFCNT %p incremented to %d\n", + refcnt, refcnt->refcnt ); + } + return refcnt; } /** diff --git a/src/include/gpxe/refcnt.h b/src/include/gpxe/refcnt.h index 0930a5777..68e0fd4b0 100644 --- a/src/include/gpxe/refcnt.h +++ b/src/include/gpxe/refcnt.h @@ -38,7 +38,7 @@ struct refcnt { void ( * free ) ( struct refcnt *refcnt ); }; -extern void ref_get ( struct refcnt *refcnt ); +extern struct refcnt * ref_get ( struct refcnt *refcnt ); extern void ref_put ( struct refcnt *refcnt ); #endif /* _GPXE_REFCNT_H */