提交 25860c3b 编写于 作者: P Paul Gortmaker 提交者: 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: NPaul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 e83504f7
......@@ -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);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册