From patchwork Sat Oct 3 07:48:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1376184 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=THiN5zzg; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C3JvQ39b4z9sTR for ; Sat, 3 Oct 2020 17:50:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FBWxPhM35+0WIPeBU/RiLyWi+06BWOR0476s4yXl1zQ=; b=THiN5zzg93TL+C9uVvZ3Gw6jx bjIKVuJIhU52nkylgfcLs6Eu+ttwMXw1Y6tgvDSaSG79ptRq9urgr+WFYA3ySXrsHuQhFEhzxDrxk pTBiLzn/xsP84fwPXhtOlSzBiQrtmqPPchuITIz8mvJGJo8Ws99I0t4/p6Q/4vBgyLxco40uX4utr akQIUP1dR3Ra18JRX8EBYnCL4cUG6Fk+aqD3nxy8wWJ4qKRgn5fI2FT4vFtDjKs0m+MBSJX1wTwNc KthSoSrrMJ6cf+RaG0FLKw2dH4GiCcWi9t417DS1q0OHuelcQVNTuZV2cYDU9qPONBcIyFqD/es2T pEDoUEi/w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kOcHm-00025h-TU; Sat, 03 Oct 2020 07:48:54 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kOcHb-00022U-Om for openwrt-devel@lists.openwrt.org; Sat, 03 Oct 2020 07:48:45 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id ECC363F89; Sat, 3 Oct 2020 09:48:34 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 42957c50; Sat, 3 Oct 2020 09:48:18 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Subject: [PATCH uci 5/6] uci: silence UBSAN error by using offsetof macro from compiler Date: Sat, 3 Oct 2020 09:48:29 +0200 Message-Id: <20201003074830.948-6-ynezz@true.cz> In-Reply-To: <20201003074830.948-1-ynezz@true.cz> References: <20201003074830.948-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201003_034843_972167_4B0C2F41 X-CRM114-Status: GOOD ( 17.19 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Fixes following ubdefined-behavior as reported by clang version 10.0.0-4ubuntu1~18.04.2: delta.c:139:52: runtime error: member access within null pointer of type 'struct uci_element' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior delta.c:139:52 Signed-off-by: Petr Štetiar --- uci.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/uci.h b/uci.h index 43f2052a00e6..b385e2be964f 100644 --- a/uci.h +++ b/uci.h @@ -34,6 +34,7 @@ extern "C" { #include #include #include +#include #define UCI_CONFDIR "/etc/config" #define UCI_SAVEDIR "/tmp/.uci" @@ -509,11 +510,6 @@ struct uci_parse_option { }; -/* linked list handling */ -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - /** * container_of - cast a member of a structure out to the containing structure * @ptr: the pointer to the member.