From 25860c3bd5bd1db236d4fd5826d76127d677dc28 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Fri, 31 Dec 2010 18:59:31 +0000 Subject: tipc: recode getsockopt error handling for better readability The existing code for the copy to user and error handling at the end of getsockopt isn't easy to follow, due to the excessive use of if/else. By simply using return where appropriate, it can be made smaller and easier to follow at the same time. Signed-off-by: Paul Gortmaker Signed-off-by: David S. Miller --- net/tipc/socket.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'net/tipc') diff --git a/net/tipc/socket.c b/net/tipc/socket.c index f972c0b4a719..1a2eb23c6223 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -1755,20 +1755,16 @@ static int getsockopt(struct socket *sock, release_sock(sk); - if (res) { - /* "get" failed */ - } - else if (len < sizeof(value)) { - res = -EINVAL; - } - else if (copy_to_user(ov, &value, sizeof(value))) { - res = -EFAULT; - } - else { - res = put_user(sizeof(value), ol); - } + if (res) + return res; /* "get" failed */ - return res; + if (len < sizeof(value)) + return -EINVAL; + + if (copy_to_user(ov, &value, sizeof(value))) + return -EFAULT; + + return put_user(sizeof(value), ol); } /** -- cgit v1.2.3-58-ga151