linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ib_umem: fix type mismatch
@ 2019-09-06 15:42 Arnd Bergmann
  2019-09-08  8:10 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2019-09-06 15:42 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Arnd Bergmann, Leon Romanovsky, Jason Gunthorpe, Shiraz Saleem,
	Leon Romanovsky, Michael J. Ruhl, linux-rdma, linux-kernel

On some 32-bit architectures, size_t is defined as 'int' rather
than 'long', causing a harmless warning:

drivers/infiniband/core/umem_odp.c:220:7: error: comparison of distinct pointer types ('typeof (umem_odp->umem.address) *' (aka 'unsigned long *') and 'typeof (umem_odp->umem.length) *' (aka 'unsigned int *')) [-Werror,-Wcompare-distinct-pointer-types]
                if (check_add_overflow(umem_odp->umem.address,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/overflow.h:59:15: note: expanded from macro 'check_add_overflow'
        (void) (&__a == &__b);                  \
                ~~~~ ^  ~~~~

As size_t is always the same length as unsigned long in all supported
architectures, change the structure definition to use the unsigned long
type for both.

Fixes: 204e3e5630c5 ("RDMA/odp: Check for overflow when computing the umem_odp end")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/rdma/ib_umem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h
index a91b2af64ec4..5dffe05402ef 100644
--- a/include/rdma/ib_umem.h
+++ b/include/rdma/ib_umem.h
@@ -44,7 +44,7 @@ struct ib_umem_odp;
 struct ib_umem {
 	struct ib_device       *ibdev;
 	struct mm_struct       *owning_mm;
-	size_t			length;
+	unsigned long		length;
 	unsigned long		address;
 	u32 writable : 1;
 	u32 is_odp : 1;
-- 
2.20.0


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

* Re: [PATCH] ib_umem: fix type mismatch
  2019-09-06 15:42 [PATCH] ib_umem: fix type mismatch Arnd Bergmann
@ 2019-09-08  8:10 ` Leon Romanovsky
  2019-09-08  8:24   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2019-09-08  8:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Doug Ledford, Jason Gunthorpe, Jason Gunthorpe, Shiraz Saleem,
	Michael J. Ruhl, linux-rdma, linux-kernel

On Fri, Sep 06, 2019 at 05:42:37PM +0200, Arnd Bergmann wrote:
> On some 32-bit architectures, size_t is defined as 'int' rather
> than 'long', causing a harmless warning:
>
> drivers/infiniband/core/umem_odp.c:220:7: error: comparison of distinct pointer types ('typeof (umem_odp->umem.address) *' (aka 'unsigned long *') and 'typeof (umem_odp->umem.length) *' (aka 'unsigned int *')) [-Werror,-Wcompare-distinct-pointer-types]
>                 if (check_add_overflow(umem_odp->umem.address,
>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/overflow.h:59:15: note: expanded from macro 'check_add_overflow'
>         (void) (&__a == &__b);                  \
>                 ~~~~ ^  ~~~~
>
> As size_t is always the same length as unsigned long in all supported
> architectures, change the structure definition to use the unsigned long
> type for both.
>
> Fixes: 204e3e5630c5 ("RDMA/odp: Check for overflow when computing the umem_odp end")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/rdma/ib_umem.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Hi Arnd,

I had slightly different fix in my submission queue, which I think is
better because it leaves length to be size_t.

https://lore.kernel.org/linux-rdma/20190908080726.30017-1-leon@kernel.org/T/#u

Thanks

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

* Re: [PATCH] ib_umem: fix type mismatch
  2019-09-08  8:10 ` Leon Romanovsky
@ 2019-09-08  8:24   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-09-08  8:24 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Jason Gunthorpe, Jason Gunthorpe, Shiraz Saleem,
	Michael J. Ruhl, linux-rdma, linux-kernel

On Sun, Sep 8, 2019 at 10:10 AM Leon Romanovsky <leonro@mellanox.com> wrote:
> On Fri, Sep 06, 2019 at 05:42:37PM +0200, Arnd Bergmann wrote:
>
> I had slightly different fix in my submission queue, which I think is
> better because it leaves length to be size_t.
>
> https://lore.kernel.org/linux-rdma/20190908080726.30017-1-leon@kernel.org/T/#u

Ok, I'm dropping my patch from my local test tree in favor of that one then.

       Arnd

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

end of thread, other threads:[~2019-09-08  8:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 15:42 [PATCH] ib_umem: fix type mismatch Arnd Bergmann
2019-09-08  8:10 ` Leon Romanovsky
2019-09-08  8:24   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).