chiark / gitweb /
libudev: always return NULL in _unref() APIs
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Nov 2013 00:15:31 +0000 (01:15 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Nov 2013 18:36:14 +0000 (19:36 +0100)
commit725d7e6cebcafef3bd4adbf76c8fa73a9b18972e
tree0f11bd0acef710d24a462b66555a2ccfe0249494
parent994e023433e020e2b3f683d5d1f2c974db580447
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.
src/libudev/libudev-device.c
src/libudev/libudev-enumerate.c
src/libudev/libudev-hwdb.c
src/libudev/libudev-monitor.c
src/libudev/libudev-queue.c