From: Joe Perches <joe@perches.com>
To: Pi-Hsun Shih <pihsun@chromium.org>
Cc: linux-wireless@vger.kernel.org,
Johannes Berg <johannes@sipsolutions.net>,
open list <linux-kernel@vger.kernel.org>,
"open list:CLANG/LLVM BUILD SUPPORT"
<clang-built-linux@googlegroups.com>
Subject: Re: [PATCH RESEND] wireless: Use offsetof instead of custom macro.
Date: Wed, 27 Nov 2019 19:53:55 -0800 [thread overview]
Message-ID: <d02f4eef9aa674cb36c1d90069a13e7bd02b7e40.camel@perches.com> (raw)
In-Reply-To: <20191128033959.87715-1-pihsun@chromium.org>
On Thu, 2019-11-28 at 11:39 +0800, Pi-Hsun Shih wrote:
> Use offsetof to calculate offset of a field to take advantage of
> compiler built-in version when possible, and avoid UBSAN warning when
> compiling with Clang:
[]
> diff --git a/include/uapi/linux/wireless.h b/include/uapi/linux/wireless.h
[]
> @@ -1090,8 +1090,7 @@ struct iw_event {
> /* iw_point events are special. First, the payload (extra data) come at
> * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
> * we omit the pointer, so start at an offset. */
> -#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
> - (char *) NULL)
> +#define IW_EV_POINT_OFF offsetof(struct iw_point, length)
> #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
> IW_EV_POINT_OFF)
This is uapi. Is offsetof guaranteed to be available?
Perhaps this is better without using another macro
#define IW_EV_POINT_OFF ((size_t)&((struct iw_point *)NULL)->length)
next prev parent reply other threads:[~2019-11-28 3:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-28 3:39 Pi-Hsun Shih
2019-11-28 3:53 ` Joe Perches [this message]
2019-11-29 4:04 ` Pi-Hsun Shih
2019-12-02 17:27 ` Nick Desaulniers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d02f4eef9aa674cb36c1d90069a13e7bd02b7e40.camel@perches.com \
--to=joe@perches.com \
--cc=clang-built-linux@googlegroups.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pihsun@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®