Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6319858ybc; Wed, 27 Nov 2019 19:56:03 -0800 (PST) X-Google-Smtp-Source: APXvYqz2G7BUhWUctunMjs+BMKcQIJAnto6hQgv+6A1eqwDE3gUxt+phL1EPMFviej6Ii6xBhgLv X-Received: by 2002:aa7:c810:: with SMTP id a16mr35349783edt.207.1574913362981; Wed, 27 Nov 2019 19:56:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574913362; cv=none; d=google.com; s=arc-20160816; b=BiywKIZwDG3Ww3O9yNCNOMvdxo/QJJSYAWJNPI9jX1Q1anO1ljMG4pdiOje3s11mqY jAcN8+zyEdkwVUGxScVY6KXUs+SMnQ+40WDRgNd/7IqnSCoMALCNZCO8XpNrxJAAoCyE 9MExzgh6G+Qkf+EPwQvUCqiFGlDK1ZdM3xyB5BDcu0J+cm4EvN+Mrn4xmE1HEpXJoo2h fUTG7eIZjCJU8E1n4RaDeZyNiiUscRPVDUbWwtwR/bie+KrkIPEQ8+lrm7y/hD2c153c qSt/dpkUbBORt3KJY0LFzodex/YESLR8oOBZ7UJ42npCjmyOf5f67dMo5JhPE+9yp3D6 7QTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=WhUN3iAUZYNhDUJaXF3fzwe5GfThyvoo9va/gqbGdHA=; b=oCjRVkkrOjQiUjFgeQNGKekm0LEmYIKRW4SSvlbHkSriGur43v8FACbeVGo9IVu1fo wGDfTOpJE1I6uHjk1hGcGpYa9dKOcj7o2QXdgFSWQbCluxGCMqJ8k8PMj58aYvOnSZnj CYgr9AtoGTMT9+/QM393a+EH7eg8BPLQgDwVzFWu7ZpTRmUxG1ff0JaSFneF1MpRxM0/ ioKL8XrLimZx1b7P1r/tlq+gvlDede/HpRI901VziiO/HUjIWUb6zw90DXlvQOyd/KIs UKegV9WBR+h0DJevIQS9fVzfOeplUetQQMr46MnYaFW68duwuS83obD0AyiJcKYSiMOP VeSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12si1781344eja.194.2019.11.27.19.55.32; Wed, 27 Nov 2019 19:56:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbfK1DyY (ORCPT + 99 others); Wed, 27 Nov 2019 22:54:24 -0500 Received: from smtprelay0023.hostedemail.com ([216.40.44.23]:45784 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726695AbfK1DyY (ORCPT ); Wed, 27 Nov 2019 22:54:24 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id D0883180A8128; Thu, 28 Nov 2019 03:54:22 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:4250:4321:5007:10004:10400:10848:11026:11232:11473:11658:11914:12043:12296:12297:12740:12760:12895:13069:13138:13231:13311:13357:13439:14659:14819:21080:21451:21627:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: cord05_261e104f2dd33 X-Filterd-Recvd-Size: 1920 Received: from XPS-9350.home (unknown [47.151.135.224]) (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA; Thu, 28 Nov 2019 03:54:21 +0000 (UTC) Message-ID: Subject: Re: [PATCH RESEND] wireless: Use offsetof instead of custom macro. From: Joe Perches To: Pi-Hsun Shih Cc: linux-wireless@vger.kernel.org, Johannes Berg , open list , "open list:CLANG/LLVM BUILD SUPPORT" Date: Wed, 27 Nov 2019 19:53:55 -0800 In-Reply-To: <20191128033959.87715-1-pihsun@chromium.org> References: <20191128033959.87715-1-pihsun@chromium.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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)