diff mbox series

[-next] io_uring: Fix unused function warnings

Message ID 20200304075352.31132-1-yuehaibing@huawei.com
State New, archived
Headers show
Series [-next] io_uring: Fix unused function warnings | expand

Commit Message

YueHaibing March 4, 2020, 7:53 a.m. UTC
If CONFIG_NET is not set, gcc warns:

fs/io_uring.c:3110:12: warning: io_setup_async_msg defined but not used [-Wunused-function]
 static int io_setup_async_msg(struct io_kiocb *req,
            ^~~~~~~~~~~~~~~~~~

There are many funcions wraped by CONFIG_NET, move them
together to simplify code, also fix this warning.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 fs/io_uring.c | 98 ++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 57 insertions(+), 41 deletions(-)

Comments

Stefano Garzarella March 4, 2020, 4:48 p.m. UTC | #1
On Wed, Mar 04, 2020 at 03:53:52PM +0800, YueHaibing wrote:
> If CONFIG_NET is not set, gcc warns:
> 
> fs/io_uring.c:3110:12: warning: io_setup_async_msg defined but not used [-Wunused-function]
>  static int io_setup_async_msg(struct io_kiocb *req,
>             ^~~~~~~~~~~~~~~~~~
> 
> There are many funcions wraped by CONFIG_NET, move them
> together to simplify code, also fix this warning.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  fs/io_uring.c | 98 ++++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 57 insertions(+), 41 deletions(-)
> 

Since the code under the ifdef/else/endif blocks now are huge, would it make
sense to add some comments for better readability?

I mean something like this:

#if defined(CONFIG_NET)
...
#else /* !CONFIG_NET */
...
#endif /* CONFIG_NET */


Thanks,
Stefano
Jens Axboe March 4, 2020, 6:37 p.m. UTC | #2
On 3/4/20 9:48 AM, Stefano Garzarella wrote:
> On Wed, Mar 04, 2020 at 03:53:52PM +0800, YueHaibing wrote:
>> If CONFIG_NET is not set, gcc warns:
>>
>> fs/io_uring.c:3110:12: warning: io_setup_async_msg defined but not used [-Wunused-function]
>>  static int io_setup_async_msg(struct io_kiocb *req,
>>             ^~~~~~~~~~~~~~~~~~
>>
>> There are many funcions wraped by CONFIG_NET, move them
>> together to simplify code, also fix this warning.
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>>  fs/io_uring.c | 98 ++++++++++++++++++++++++++++++++++-------------------------
>>  1 file changed, 57 insertions(+), 41 deletions(-)
>>
> 
> Since the code under the ifdef/else/endif blocks now are huge, would it make
> sense to add some comments for better readability?
> 
> I mean something like this:
> 
> #if defined(CONFIG_NET)
> ...
> #else /* !CONFIG_NET */
> ...
> #endif /* CONFIG_NET */

I applied it with that addition. Also had to adapt it quite a bit, as
the prototypes changed. I'm guessing the branch used was a few days
old?
diff mbox series

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index b7c178f9..89cdc6e 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3420,6 +3420,7 @@  static int io_sync_file_range(struct io_kiocb *req, struct io_kiocb **nxt,
 	return 0;
 }
 
+#if defined(CONFIG_NET)
 static int io_setup_async_msg(struct io_kiocb *req,
 			      struct io_async_msghdr *kmsg)
 {
@@ -3437,7 +3438,6 @@  static int io_setup_async_msg(struct io_kiocb *req,
 
 static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
-#if defined(CONFIG_NET)
 	struct io_sr_msg *sr = &req->sr_msg;
 	struct io_async_ctx *io = req->io;
 	int ret;
@@ -3463,15 +3463,11 @@  static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 	if (!ret)
 		req->flags |= REQ_F_NEED_CLEANUP;
 	return ret;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
 static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt,
 		      bool force_nonblock)
 {
-#if defined(CONFIG_NET)
 	struct io_async_msghdr *kmsg = NULL;
 	struct socket *sock;
 	int ret;
@@ -3525,15 +3521,11 @@  static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt,
 		req_set_fail_links(req);
 	io_put_req_find_next(req, nxt);
 	return 0;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
 static int io_send(struct io_kiocb *req, struct io_kiocb **nxt,
 		   bool force_nonblock)
 {
-#if defined(CONFIG_NET)
 	struct socket *sock;
 	int ret;
 
@@ -3576,9 +3568,6 @@  static int io_send(struct io_kiocb *req, struct io_kiocb **nxt,
 		req_set_fail_links(req);
 	io_put_req_find_next(req, nxt);
 	return 0;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
 static int __io_recvmsg_copy_hdr(struct io_kiocb *req, struct io_async_ctx *io)
@@ -3691,7 +3680,6 @@  static struct io_buffer *io_recv_buffer_select(struct io_kiocb *req,
 static int io_recvmsg_prep(struct io_kiocb *req,
 			   const struct io_uring_sqe *sqe)
 {
-#if defined(CONFIG_NET)
 	struct io_sr_msg *sr = &req->sr_msg;
 	struct io_async_ctx *io = req->io;
 	int ret;
@@ -3716,15 +3704,11 @@  static int io_recvmsg_prep(struct io_kiocb *req,
 	if (!ret)
 		req->flags |= REQ_F_NEED_CLEANUP;
 	return ret;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
 static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt,
 		      bool force_nonblock)
 {
-#if defined(CONFIG_NET)
 	struct io_async_msghdr *kmsg = NULL;
 	struct socket *sock;
 	int ret, cflags = 0;
@@ -3785,15 +3769,11 @@  static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt,
 		req_set_fail_links(req);
 	io_put_req_find_next(req, nxt);
 	return 0;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
 static int io_recv(struct io_kiocb *req, struct io_kiocb **nxt,
 		   bool force_nonblock)
 {
-#if defined(CONFIG_NET)
 	struct io_buffer *kbuf = NULL;
 	struct socket *sock;
 	int ret, cflags = 0;
@@ -3850,15 +3830,10 @@  static int io_recv(struct io_kiocb *req, struct io_kiocb **nxt,
 		req_set_fail_links(req);
 	io_put_req_find_next(req, nxt);
 	return 0;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
-
 static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
-#if defined(CONFIG_NET)
 	struct io_accept *accept = &req->accept;
 
 	if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
@@ -3870,12 +3845,8 @@  static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 	accept->addr_len = u64_to_user_ptr(READ_ONCE(sqe->addr2));
 	accept->flags = READ_ONCE(sqe->accept_flags);
 	return 0;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
-#if defined(CONFIG_NET)
 static int __io_accept(struct io_kiocb *req, struct io_kiocb **nxt,
 		       bool force_nonblock)
 {
@@ -3910,12 +3881,10 @@  static void io_accept_finish(struct io_wq_work **workptr)
 	if (nxt)
 		io_wq_assign_next(workptr, nxt);
 }
-#endif
 
 static int io_accept(struct io_kiocb *req, struct io_kiocb **nxt,
 		     bool force_nonblock)
 {
-#if defined(CONFIG_NET)
 	int ret;
 
 	ret = __io_accept(req, nxt, force_nonblock);
@@ -3924,14 +3893,10 @@  static int io_accept(struct io_kiocb *req, struct io_kiocb **nxt,
 		return -EAGAIN;
 	}
 	return 0;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
 static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
-#if defined(CONFIG_NET)
 	struct io_connect *conn = &req->connect;
 	struct io_async_ctx *io = req->io;
 
@@ -3948,15 +3913,11 @@  static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
 	return move_addr_to_kernel(conn->addr, conn->addr_len,
 					&io->connect.address);
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
 static int io_connect(struct io_kiocb *req, struct io_kiocb **nxt,
 		      bool force_nonblock)
 {
-#if defined(CONFIG_NET)
 	struct io_async_ctx __io, *io;
 	unsigned file_flags;
 	int ret;
@@ -3994,11 +3955,66 @@  static int io_connect(struct io_kiocb *req, struct io_kiocb **nxt,
 	io_cqring_add_event(req, ret);
 	io_put_req_find_next(req, nxt);
 	return 0;
+}
 #else
+static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+{
+	return -EOPNOTSUPP;
+}
+
+static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt,
+		      bool force_nonblock)
+{
 	return -EOPNOTSUPP;
-#endif
 }
 
+static int io_send(struct io_kiocb *req, struct io_kiocb **nxt,
+		   bool force_nonblock)
+{
+	return -EOPNOTSUPP;
+}
+
+static int io_recvmsg_prep(struct io_kiocb *req,
+			   const struct io_uring_sqe *sqe)
+{
+	return -EOPNOTSUPP;
+}
+
+static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt,
+		      bool force_nonblock)
+{
+	return -EOPNOTSUPP;
+}
+
+static int io_recv(struct io_kiocb *req, struct io_kiocb **nxt,
+		   bool force_nonblock)
+{
+	return -EOPNOTSUPP;
+}
+
+static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+{
+	return -EOPNOTSUPP;
+}
+
+static int io_accept(struct io_kiocb *req, struct io_kiocb **nxt,
+		     bool force_nonblock)
+{
+	return -EOPNOTSUPP;
+}
+
+static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+{
+	return -EOPNOTSUPP;
+}
+
+static int io_connect(struct io_kiocb *req, struct io_kiocb **nxt,
+		      bool force_nonblock)
+{
+	return -EOPNOTSUPP;
+}
+#endif
+
 struct io_poll_table {
 	struct poll_table_struct pt;
 	struct io_kiocb *req;