HomeFreeBSD

ibcore: Clean up INIT_UDATA() and INIT_UDATA_BUF_OR_NULL() macro usage.

Description

ibcore: Clean up INIT_UDATA() and INIT_UDATA_BUF_OR_NULL() macro usage.

We get a harmless warning about the fact that we use the result of a
multiplication as a condition in INIT_UDATA_BUF_OR_NULL():

uverbs_main.c: In function 'ib_uverbs_write':
error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]

This avoids the problem by using an inline function in place of
the macro.

After changing INIT_UDATA_BUF_OR_NULL() to an inline function,
do the same change to INIT_UDATA() for consistency.

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.

Linux commit:
12f727721eee61b3d19dedb95cb893b2baa9fe41
40a203396cc1c239f2e71c47c66ed03097123d2c

MFC after: 1 week
Reviewed by: kib
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 05f4691919d6d0219795a1ca8ad84dd82d87b1cf)

Details

Provenance
hselaskyAuthored on Jun 16 2021, 1:01 PM
jhbCommitted on Mar 22 2023, 10:27 PM
Parents
rG8f88432a1de0: ofed: quiet gcc -Wint-in-bool-context
Branches
Unknown
Tags
Unknown