[PATCH 28/44] kdbus: Cleanup kdbus_queue_entry_new()

From: Sergei Zviagintsev
Date: Thu Oct 08 2015 - 07:40:10 EST


Remove separate exit point as the only error case in the function is
when kdbus_staging_emit() fails. Assign a slice to temporary var first
to not clear it explicitly on error and to return an error code without
`ret' variable.

Signed-off-by: Sergei Zviagintsev <sergei@xxxxxxxx>
---
ipc/kdbus/queue.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/ipc/kdbus/queue.c b/ipc/kdbus/queue.c
index 90e8d16f5967..3c0fb3bb55da 100644
--- a/ipc/kdbus/queue.c
+++ b/ipc/kdbus/queue.c
@@ -185,7 +185,7 @@ struct kdbus_queue_entry *kdbus_queue_entry_new(struct kdbus_conn *src,
struct kdbus_staging *s)
{
struct kdbus_queue_entry *entry;
- int ret;
+ struct kdbus_pool_slice *slice;

entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (!entry)
@@ -196,19 +196,15 @@ struct kdbus_queue_entry *kdbus_queue_entry_new(struct kdbus_conn *src,
entry->conn = kdbus_conn_ref(dst);
entry->gaps = kdbus_gaps_ref(s->gaps);

- entry->slice = kdbus_staging_emit(s, src, dst);
- if (IS_ERR(entry->slice)) {
- ret = PTR_ERR(entry->slice);
- entry->slice = NULL;
- goto error;
+ slice = kdbus_staging_emit(s, src, dst);
+ if (IS_ERR(slice)) {
+ kdbus_queue_entry_free(entry);
+ return ERR_CAST(slice);
}

+ entry->slice = slice;
entry->user = src ? kdbus_user_ref(src->user) : NULL;
return entry;
-
-error:
- kdbus_queue_entry_free(entry);
- return ERR_PTR(ret);
}

/**
--
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/