tipc: recode getsockopt error handling for better readability
authorPaul Gortmaker <paul.gortmaker@windriver.com>
Fri, 31 Dec 2010 18:59:31 +0000 (18:59 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 1 Jan 2011 21:57:55 +0000 (13:57 -0800)
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 <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/socket.c

index f972c0b4a7191290619d90ba6068af92aa1ab111..1a2eb23c62237738f54bdea0f0fb626bd861b7f6 100644 (file)
@@ -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);
 }
 
 /**