diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-09-06 23:34:26 +0200 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2017-09-27 14:54:19 +0200 |
commit | 40a203396cc1c239f2e71c47c66ed03097123d2c (patch) | |
tree | 4d59b97985094f95b2a18fb2ce5e22759155f606 /drivers/infiniband/core/uverbs.h | |
parent | IB/uverbs: clean up INIT_UDATA_BUF_OR_NULL usage (diff) | |
download | linux-40a203396cc1c239f2e71c47c66ed03097123d2c.tar.xz linux-40a203396cc1c239f2e71c47c66ed03097123d2c.zip |
IB/uverbs: clean up INIT_UDATA() macro usage
After changing INIT_UDATA_BUF_OR_NULL() to an inline function,
this does the same change to INIT_UDATA for consistency.
I'm keeping it separate as this part is much larger and
we wouldn't want to backport this to stable kernels if we
ever want to address the gcc warnings by backporting the
first patch.
Again, using an inline function gives us better type
safety here among other issues with macros. I'm using
u64_to_user_ptr() to convert the user pointer to simplify
the logic rather than adding lots of new type casts.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/core/uverbs.h')
-rw-r--r-- | drivers/infiniband/core/uverbs.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index a8f104a4a91b..ee2739ae4305 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -47,13 +47,17 @@ #include <rdma/ib_umem.h> #include <rdma/ib_user_verbs.h> -#define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \ - do { \ - (udata)->inbuf = (const void __user *) (ibuf); \ - (udata)->outbuf = (void __user *) (obuf); \ - (udata)->inlen = (ilen); \ - (udata)->outlen = (olen); \ - } while (0) +static inline void +ib_uverbs_init_udata(struct ib_udata *udata, + const void __user *ibuf, + void __user *obuf, + size_t ilen, size_t olen) +{ + udata->inbuf = ibuf; + udata->outbuf = obuf; + udata->inlen = ilen; + udata->outlen = olen; +} static inline void ib_uverbs_init_udata_buf_or_null(struct ib_udata *udata, @@ -61,7 +65,9 @@ ib_uverbs_init_udata_buf_or_null(struct ib_udata *udata, void __user *obuf, size_t ilen, size_t olen) { - INIT_UDATA(udata, ilen ? ibuf : NULL, olen ? obuf : NULL, ilen, olen); + ib_uverbs_init_udata(udata, + ilen ? ibuf : NULL, olen ? obuf : NULL, + ilen, olen); } /* |