Use goto to handle error paths in conventional way. Use conditional operator instead of `remote_ret' var. Update the comment on waking up remote peer.
Signed-off-by: Sergei Zviagintsev <[email protected]> --- ipc/kdbus/connection.c | 52 ++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index 6ee688d3de53..081f248339f5 100644 --- a/ipc/kdbus/connection.c +++ b/ipc/kdbus/connection.c @@ -820,47 +820,37 @@ static int kdbus_conn_entry_sync_attach(struct kdbus_conn *conn_dst, struct kdbus_reply *reply_wake) { struct kdbus_queue_entry *entry; - int remote_ret, ret = 0; + int ret = 0; mutex_lock(&reply_wake->reply_dst->lock); - /* - * If we are still waiting then proceed, allocate a queue - * entry and attach it to the reply object - */ - if (reply_wake->waiting) { - entry = kdbus_conn_entry_make(reply_wake->reply_src, conn_dst, - staging); - if (IS_ERR(entry)) - ret = PTR_ERR(entry); - else - /* Attach the entry to the reply object */ - reply_wake->queue_entry = entry; - } else { + if (!reply_wake->waiting) { ret = -ECONNRESET; + goto wake_up_remote; } /* - * Update the reply object and wake up remote peer only - * on appropriate return codes - * - * * -ECOMM: if the replying connection failed with -ECOMM - * then wakeup remote peer with -EREMOTEIO - * - * We do this to differenciate between -ECOMM errors - * from the original sender perspective: - * -ECOMM error during the sync send and - * -ECOMM error during the sync reply, this last - * one is rewritten to -EREMOTEIO - * - * * Wake up on all other return codes. + * We are still waiting. Allocate a queue entry and attach it to the + * reply object. */ - remote_ret = ret; + entry = kdbus_conn_entry_make(reply_wake->reply_src, conn_dst, staging); + if (IS_ERR(entry)) { + ret = PTR_ERR(entry); + goto wake_up_remote; + } - if (ret == -ECOMM) - remote_ret = -EREMOTEIO; + reply_wake->queue_entry = entry; - kdbus_sync_reply_wakeup(reply_wake, remote_ret); + /* + * If the replying connection failed with -ECOMM then wakeup remote peer + * with -EREMOTEIO. We do this to differentiate between -ECOMM errors + * from the original sender perspective: + * * -ECOMM error during the sync send and + * * -ECOMM error during the sync reply, this last one is rewritten + * to -EREMOTEIO + */ +wake_up_remote: + kdbus_sync_reply_wakeup(reply_wake, (ret == -ECOMM) ? -EREMOTEIO : ret); kdbus_reply_unlink(reply_wake); mutex_unlock(&reply_wake->reply_dst->lock); -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

