All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aio: remove redundant check in ioctx_alloc()
@ 2019-01-04 14:31 Chengguang Xu
  2019-01-04 16:03 ` Jeff Moyer
  0 siblings, 1 reply; 2+ messages in thread
From: Chengguang Xu @ 2019-01-04 14:31 UTC (permalink / raw)
  To: bcrl, viro; +Cc: linux-aio, linux-fsdevel, Chengguang Xu

We don't have to check if nr_events is zero in
ioctx_alloc() because the caller has already
done that.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/aio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/aio.c b/fs/aio.c
index b906ff70c90f..7b26c4feb0de 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -720,7 +720,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
 		return ERR_PTR(-EINVAL);
 	}
 
-	if (!nr_events || (unsigned long)max_reqs > aio_max_nr)
+	if ((unsigned long)max_reqs > aio_max_nr)
 		return ERR_PTR(-EAGAIN);
 
 	ctx = kmem_cache_zalloc(kioctx_cachep, GFP_KERNEL);
-- 
2.17.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] aio: remove redundant check in ioctx_alloc()
  2019-01-04 14:31 [PATCH] aio: remove redundant check in ioctx_alloc() Chengguang Xu
@ 2019-01-04 16:03 ` Jeff Moyer
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Moyer @ 2019-01-04 16:03 UTC (permalink / raw)
  To: Chengguang Xu; +Cc: bcrl, viro, linux-aio, linux-fsdevel

Chengguang Xu <cgxu519@gmx.com> writes:

> We don't have to check if nr_events is zero in
> ioctx_alloc() because the caller has already
> done that.

No, this is not a redundant check.  We did some math on that value and
we have to make sure it didn't overflow.

Cheers,
Jeff

>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
>  fs/aio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/aio.c b/fs/aio.c
> index b906ff70c90f..7b26c4feb0de 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -720,7 +720,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
>  		return ERR_PTR(-EINVAL);
>  	}
>  
> -	if (!nr_events || (unsigned long)max_reqs > aio_max_nr)
> +	if ((unsigned long)max_reqs > aio_max_nr)
>  		return ERR_PTR(-EAGAIN);
>  
>  	ctx = kmem_cache_zalloc(kioctx_cachep, GFP_KERNEL);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-04 16:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-04 14:31 [PATCH] aio: remove redundant check in ioctx_alloc() Chengguang Xu
2019-01-04 16:03 ` Jeff Moyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.