summaryrefslogtreecommitdiff
path: root/src/libudev/libudev-hwdb.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-19 01:15:31 +0100
committerAnthony G. Basile <blueness@gentoo.org>2014-01-09 15:34:16 -0500
commit7edf99d8905af253236732cf538d2b6d1a0c4243 (patch)
tree0acb27999fe840e9308be337e729e4314514040c /src/libudev/libudev-hwdb.c
parentfc5bd12597c663380c39d6de3bbef894e6d563f8 (diff)
libudev: always return NULL in _unref() APIs
Returning anything else but NULL would suggest the caller's reference might still be valid, but it isn't, because the caller just invoked _unref() after all. This turns the return value into a typesafe shortcut that allows unreffing and resetting a reference in one line. In contrast to solutions for this which take a pointer to a pointer to accomplish the same this solution is just syntactic sugar the developer can make use of but doesn't have to, and this is particularly useful when immediately unreffing objects returned by function calls. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev/libudev-hwdb.c')
-rw-r--r--src/libudev/libudev-hwdb.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c
index 335f5b775a..9368600b25 100644
--- a/src/libudev/libudev-hwdb.c
+++ b/src/libudev/libudev-hwdb.c
@@ -334,14 +334,14 @@ _public_ struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb) {
* Drop a reference of a hwdb context. If the refcount reaches zero,
* all resources of the hwdb context will be released.
*
- * Returns: the passed hwdb context if it has still an active reference, or #NULL otherwise.
+ * Returns: #NULL
**/
_public_ struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb) {
if (!hwdb)
return NULL;
hwdb->refcount--;
if (hwdb->refcount > 0)
- return hwdb;
+ return NULL;
if (hwdb->map)
munmap((void *)hwdb->map, hwdb->st.st_size);
if (hwdb->f)