* [PATCH] kdbus: Make kdbus_bus_unref() return void
@ 2015-04-22 11:50 Tobias Klauser
2015-04-22 12:01 ` David Herrmann
0 siblings, 1 reply; 3+ messages in thread
From: Tobias Klauser @ 2015-04-22 11:50 UTC (permalink / raw)
To: Greg Kroah-Hartman, Daniel Mack, David Herrmann, Djalal Harouni
Cc: linux-kernel
kdbus_bus_unref() always returns NULL and none of its callers use the
return value, so make it return void.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
ipc/kdbus/bus.c | 5 +----
ipc/kdbus/bus.h | 2 +-
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/ipc/kdbus/bus.c b/ipc/kdbus/bus.c
index 9d0679e..dce7b08 100644
--- a/ipc/kdbus/bus.c
+++ b/ipc/kdbus/bus.c
@@ -202,14 +202,11 @@ struct kdbus_bus *kdbus_bus_ref(struct kdbus_bus *bus)
*
* Release a reference. If the reference count drops to 0, the bus will be
* freed.
- *
- * Return: NULL
*/
-struct kdbus_bus *kdbus_bus_unref(struct kdbus_bus *bus)
+void kdbus_bus_unref(struct kdbus_bus *bus)
{
if (bus)
kdbus_node_unref(&bus->node);
- return NULL;
}
/**
diff --git a/ipc/kdbus/bus.h b/ipc/kdbus/bus.h
index 5bea5ef..266af60 100644
--- a/ipc/kdbus/bus.h
+++ b/ipc/kdbus/bus.h
@@ -84,7 +84,7 @@ struct kdbus_bus {
};
struct kdbus_bus *kdbus_bus_ref(struct kdbus_bus *bus);
-struct kdbus_bus *kdbus_bus_unref(struct kdbus_bus *bus);
+void kdbus_bus_unref(struct kdbus_bus *bus);
struct kdbus_conn *kdbus_bus_find_conn_by_id(struct kdbus_bus *bus, u64 id);
void kdbus_bus_broadcast(struct kdbus_bus *bus,
--
2.2.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kdbus: Make kdbus_bus_unref() return void
2015-04-22 11:50 [PATCH] kdbus: Make kdbus_bus_unref() return void Tobias Klauser
@ 2015-04-22 12:01 ` David Herrmann
2015-04-22 12:12 ` Tobias Klauser
0 siblings, 1 reply; 3+ messages in thread
From: David Herrmann @ 2015-04-22 12:01 UTC (permalink / raw)
To: Tobias Klauser
Cc: Greg Kroah-Hartman, Daniel Mack, David Herrmann, Djalal Harouni,
linux-kernel
Hi
On Wed, Apr 22, 2015 at 1:50 PM, Tobias Klauser <tklauser@distanz.ch> wrote:
> kdbus_bus_unref() always returns NULL and none of its callers use the
> return value, so make it return void.
>
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
All our destructors return NULL, which allows simple assignment during
destruction:
foo->bus = kdbus_bus_unref(foo->bus);
And our destructors ignore NULL, so no reason to conditionalize the
call to unref(). This simplifies our error-paths a lot, and I'd like
to keep it that way.
I'd prefer to stay uniform across our code-base and keep returning
NULL. It's neither a fast-path, nor do return values require any
memory writes (usually register passing, iirc).
Thanks
David
> ---
> ipc/kdbus/bus.c | 5 +----
> ipc/kdbus/bus.h | 2 +-
> 2 files changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/ipc/kdbus/bus.c b/ipc/kdbus/bus.c
> index 9d0679e..dce7b08 100644
> --- a/ipc/kdbus/bus.c
> +++ b/ipc/kdbus/bus.c
> @@ -202,14 +202,11 @@ struct kdbus_bus *kdbus_bus_ref(struct kdbus_bus *bus)
> *
> * Release a reference. If the reference count drops to 0, the bus will be
> * freed.
> - *
> - * Return: NULL
> */
> -struct kdbus_bus *kdbus_bus_unref(struct kdbus_bus *bus)
> +void kdbus_bus_unref(struct kdbus_bus *bus)
> {
> if (bus)
> kdbus_node_unref(&bus->node);
> - return NULL;
> }
>
> /**
> diff --git a/ipc/kdbus/bus.h b/ipc/kdbus/bus.h
> index 5bea5ef..266af60 100644
> --- a/ipc/kdbus/bus.h
> +++ b/ipc/kdbus/bus.h
> @@ -84,7 +84,7 @@ struct kdbus_bus {
> };
>
> struct kdbus_bus *kdbus_bus_ref(struct kdbus_bus *bus);
> -struct kdbus_bus *kdbus_bus_unref(struct kdbus_bus *bus);
> +void kdbus_bus_unref(struct kdbus_bus *bus);
>
> struct kdbus_conn *kdbus_bus_find_conn_by_id(struct kdbus_bus *bus, u64 id);
> void kdbus_bus_broadcast(struct kdbus_bus *bus,
> --
> 2.2.2
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kdbus: Make kdbus_bus_unref() return void
2015-04-22 12:01 ` David Herrmann
@ 2015-04-22 12:12 ` Tobias Klauser
0 siblings, 0 replies; 3+ messages in thread
From: Tobias Klauser @ 2015-04-22 12:12 UTC (permalink / raw)
To: David Herrmann
Cc: Greg Kroah-Hartman, Daniel Mack, David Herrmann, Djalal Harouni,
linux-kernel
On 2015-04-22 at 14:01:05 +0200, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> On Wed, Apr 22, 2015 at 1:50 PM, Tobias Klauser <tklauser@distanz.ch> wrote:
> > kdbus_bus_unref() always returns NULL and none of its callers use the
> > return value, so make it return void.
> >
> > Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
>
> All our destructors return NULL, which allows simple assignment during
> destruction:
> foo->bus = kdbus_bus_unref(foo->bus);
> And our destructors ignore NULL, so no reason to conditionalize the
> call to unref(). This simplifies our error-paths a lot, and I'd like
> to keep it that way.
Thanks for the explanation. I didn't consider this - and didn't even
look at the other *_unref() for that matter :(
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-22 12:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-22 11:50 [PATCH] kdbus: Make kdbus_bus_unref() return void Tobias Klauser
2015-04-22 12:01 ` David Herrmann
2015-04-22 12:12 ` Tobias Klauser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox