[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <97F399F1-3A57-494E-916B-EB6EC446B6F2@mellanox.com>
Date: Fri, 26 Aug 2016 09:52:40 +0000
From: Majd Dibbiny <majd@...lanox.com>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
CC: Matan Barak <matanb@...lanox.com>,
Leon Romanovsky <leonro@...lanox.com>,
"dledford@...hat.com" <dledford@...hat.com>,
"sean.hefty@...el.com" <sean.hefty@...el.com>,
"hal.rosenstock@...il.com" <hal.rosenstock@...il.com>,
"linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>
Subject: Re: [PATCH] IB/mlx5: Fix a parameter of find_first_bit
Acked-by: Majd Dibbiny <majd@...lanox.com>
> On Aug 26, 2016, at 8:25 AM, Christophe JAILLET <christophe.jaillet@...adoo.fr> wrote:
>
> The 2nd parameter of 'find_first_bit' is the number of bits to search.
> In this case, we are passing 'sizeof(tmp)' which is likely to be 4 or 8
> because 'tmp' is an 'unsigned long'.
>
> It is likely that the number of bits of 'tmp' was expected here. So use
> BITS_PER_LONG instead.
>
> It has been spotted by the following coccinelle script:
> @@
> expression ret, x;
>
> @@
> * ret = \(find_first_bit \| find_first_zero_bit\) (x, sizeof(...));
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
> __ffs could be used to reduce code verbosity
> ---
> drivers/infiniband/hw/mlx5/mem.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/mem.c b/drivers/infiniband/hw/mlx5/mem.c
> index 40df2cca0609..996b54e366b0 100644
> --- a/drivers/infiniband/hw/mlx5/mem.c
> +++ b/drivers/infiniband/hw/mlx5/mem.c
> @@ -71,7 +71,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
>
> addr = addr >> page_shift;
> tmp = (unsigned long)addr;
> - m = find_first_bit(&tmp, sizeof(tmp));
> + m = find_first_bit(&tmp, BITS_PER_LONG);
> skip = 1 << m;
> mask = skip - 1;
> i = 0;
> @@ -81,7 +81,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
> for (k = 0; k < len; k++) {
> if (!(i & mask)) {
> tmp = (unsigned long)pfn;
> - m = min_t(unsigned long, m, find_first_bit(&tmp, sizeof(tmp)));
> + m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG));
> skip = 1 << m;
> mask = skip - 1;
> base = pfn;
> @@ -89,7 +89,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
> } else {
> if (base + p != pfn) {
> tmp = (unsigned long)p;
> - m = find_first_bit(&tmp, sizeof(tmp));
> + m = find_first_bit(&tmp, BITS_PER_LONG);
> skip = 1 << m;
> mask = skip - 1;
> base = pfn;
> --
> 2.7.4
>
>
> ---
> L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
> https://www.avast.com/antivirus
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists