소스 검색

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>
Paul Gortmaker 14 년 전
부모
커밋
25860c3bd5
1개의 변경된 파일9개의 추가작업 그리고 13개의 파일을 삭제
  1. 9 13
      net/tipc/socket.c

+ 9 - 13
net/tipc/socket.c

@@ -1755,20 +1755,16 @@ static int getsockopt(struct socket *sock,
 
 
 	release_sock(sk);
 	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);
 }
 }
 
 
 /**
 /**