summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2010-12-31 18:59:31 +0000
committerDavid S. Miller <davem@davemloft.net>2011-01-01 13:57:55 -0800
commit25860c3bd5bd1db236d4fd5826d76127d677dc28 (patch)
tree68ad705820b95452a49574e056c89d61cd1b69e5 /net
parente83504f72456809cdbdbc91700d3ba6370c9da1c (diff)
downloadblackbird-op-linux-25860c3bd5bd1db236d4fd5826d76127d677dc28.tar.gz
blackbird-op-linux-25860c3bd5bd1db236d4fd5826d76127d677dc28.zip
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 <paul.gortmaker@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/socket.c22
1 files changed, 9 insertions, 13 deletions
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);
}
/**
OpenPOWER on IntegriCloud