Commit 25860c3b authored by Paul Gortmaker's avatar Paul Gortmaker Committed by David S. Miller

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: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e83504f7
...@@ -1755,20 +1755,16 @@ static int getsockopt(struct socket *sock, ...@@ -1755,20 +1755,16 @@ static int getsockopt(struct socket *sock,
release_sock(sk); release_sock(sk);
if (res) { if (res)
/* "get" failed */ return 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);
}
return res; if (len < sizeof(value))
return -EINVAL;
if (copy_to_user(ov, &value, sizeof(value)))
return -EFAULT;
return put_user(sizeof(value), ol);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment