fs/pipe.c: merge if statements with identical conditions
PATCH 1/1 fs/pipe.c: merge if statements with identical conditions
As 'head' is not updated after head+1 is assigned to pipe->head, the condition being tested here is exactly the same as in the big if statement just above. Merge the two bodies.
--- fs/pipe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/pipe.c +1 -3
@@ -547,10 +547,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)if (!iov_iter_count (from))break ; - } - -if (!pipe_full (head, pipe->tail, pipe->max_usage))continue ; + }/* Wait for buffer space to become available. */ if ((filp->f_flags & O_NONBLOCK) ||
Signature · 1 line
2.48.1
Quoted 15 lines · Rasmus Villemoes
As 'head' is not updated after head+1 is assigned to
pipe->head, the condition being tested here is exactly the same as in the big if statement just above. Merge the two bodies.Signed-off-by Rasmus Villemoes <[email protected]>--- fs/pipe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fs/pipe.c +0
-0@@ -547,10 +547,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
fs/pipe.c pipe_write(struct kiocb *iocb, struct iov_iter *from) · line 554
Quoted 10 lines
fs/pipe.c +1
-3if (!iov_iter_count (from))break ; - } - -if (!pipe_full (head, pipe->tail, pipe->max_usage))continue ; + }/* Wait for buffer space to become available. */ if ((filp->f_flags & O_NONBLOCK) ||
I already posted this :)
It is hanging out in the vfs trees (and -next), see
https://lore.kernel.org/linux-fsdevel/[email protected]/
Quoted 24 lines · Mateusz Guzik
Quoted 23 lines · Rasmus Villemoes
As 'head' is not updated after head+1 is assigned to
pipe->head, the condition being tested here is exactly the same as in the big if statement just above. Merge the two bodies.Signed-off-by Rasmus Villemoes <[email protected]>--- fs/pipe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fs/pipe.c +1
-3@@ -547,10 +547,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)if (!iov_iter_count (from))break ; - } - -if (!pipe_full (head, pipe->tail, pipe->max_usage))continue ; + }
Quoted 5 lines
fs/pipe.c pipe_write(struct kiocb *iocb, struct iov_iter *from) · line 554
Quoted 2 lines
fs/pipe.c +0
-0/* Wait for buffer space to become available. */ if ((filp->f_flags & O_NONBLOCK) ||I already posted this :)
Ah, never mind then, also for that other patch I just sent. Just stumbled on those while trying to proof-read the pipe code.
Rasmus
Quoted 4 lines · Rasmus Villemoes
As 'head' is not updated after head+1 is assigned to
pipe->head, the condition being tested here is exactly the same as in the big if statement just above. Merge the two bodies.
Yes.
But Mateusz has already sent the same patch, please see
[PATCH 1/3] pipe: drop an always true check in anon_pipe_write() https://lore.kernel.org/all/[email protected]/
Oleg.
Quoted 24 lines
Signed-off-by Rasmus Villemoes <[email protected]>--- fs/pipe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fs/pipe.c +1
-4@@ -547,10 +547,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)if (!iov_iter_count (from))break ; - } - -if (!pipe_full (head, pipe->tail, pipe->max_usage))continue ; + }/* Wait for buffer space to become available. */ if ((filp->f_flags & O_NONBLOCK) || --2.48.1