Skip to contentSkip to conversation

io_uring: style: redundant NULL check.

PATCH In review YANG LI 2 participants 2 messages Dec 30, 2020

Subsystems (2)
lore
Share & tools
lore

YANG LI

author
#0 lore raw

PATCH 1/1 io_uring: style: redundant NULL check.

If the pointer in kfree is empty, the function does nothing, so remove the redundant NULL check.

---
 fs/io_uring.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
fs/io_uring.c +5 -8
index 7e35283..105e188 100644
@@ -1934,8 +1934,8 @@ static void io_dismantle_req(struct io_kiocb *req)
 {
 	io_clean_op(req);
 
-	if (req->async_data)
-		kfree(req->async_data);
+	kfree(req->async_data);
+
 	if (req->file)
 		io_put_file(req, req->file, (req->flags & REQ_F_FIXED_FILE));
 	if (req->fixed_file_refs)
@@ -3537,8 +3537,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
 	ret = 0;
 out_free:
 	/* it's reportedly faster than delegating the null check to kfree() */
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return ret;
 }
 
@@ -3644,8 +3643,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
 	}
 out_free:
 	/* it's reportedly faster than delegating the null check to kfree() */
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return ret;
 }
 
@@ -6133,8 +6131,7 @@ static void __io_clean_op(struct io_kiocb *req)
 		case IORING_OP_WRITE_FIXED:
 		case IORING_OP_WRITE: {
 			struct io_async_rw *io = req->async_data;
-			if (io->free_iovec)
-				kfree(io->free_iovec);
+			kfree(io->free_iovec);
 			break;
 			}
 		case IORING_OP_RECVMSG:
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 6 lines · YANG LI

If the pointer in kfree is empty, the function does nothing, so remove the redundant NULL check.

---

Looks like you should do something with these 2 comments:

/* it's reportedly faster than delegating the null check to kfree() */

Quoted 49 lines
 fs/io_uring.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
fs/io_uring.c +5 -8
index 7e35283..105e188 100644
@@ -1934,8 +1934,8 @@ static void io_dismantle_req(struct io_kiocb *req)
 {
 	io_clean_op(req);
 
-	if (req->async_data)
-		kfree(req->async_data);
+	kfree(req->async_data);
+
 	if (req->file)
 		io_put_file(req, req->file, (req->flags & REQ_F_FIXED_FILE));
 	if (req->fixed_file_refs)
@@ -3537,8 +3537,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
 	ret = 0;
 out_free:
 	/* it's reportedly faster than delegating the null check to kfree() */
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return ret;
 }
 
@@ -3644,8 +3643,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
 	}
 out_free:
 	/* it's reportedly faster than delegating the null check to kfree() */
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return ret;
 }
 
@@ -6133,8 +6131,7 @@ static void __io_clean_op(struct io_kiocb *req)
 		case IORING_OP_WRITE_FIXED:
 		case IORING_OP_WRITE: {
 			struct io_async_rw *io = req->async_data;
-			if (io->free_iovec)
-				kfree(io->free_iovec);
+			kfree(io->free_iovec);
 			break;
 			}
 		case IORING_OP_RECVMSG:
Signature · 1 line
~Randy