aio: remove redundant check in ioctx_alloc()
PATCH 1/1 aio: remove redundant check in ioctx_alloc()
We don't have to check if nr_events is zero inioctx_alloc() because the caller has already
done that.
Signed-off-by Chengguang Xu <[email protected]>
--- fs/aio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/aio.c +1 -1
@@ -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 );
Signature · 1 line
2.17.2
Quoted 3 lines · Chengguang Xu
We don't have to check if
nr_eventsis zero inioctx_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
Quoted 19 lines
Signed-off-by Chengguang Xu <[email protected]>--- fs/aio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/aio.c +1
-1@@ -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 );