Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp145722ybi; Thu, 1 Aug 2019 16:19:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQejrZsZiHg1p8ad8XtnW+6e7Vw1nzA6Qw/vVoKh6aAtTEiPf0qddbvajH6kjVALQK3QQD X-Received: by 2002:aa7:843c:: with SMTP id q28mr57141763pfn.152.1564701597981; Thu, 01 Aug 2019 16:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564701597; cv=none; d=google.com; s=arc-20160816; b=UOzg7pcyv/fHWCuh73b/r+MEMNxrd80Gy9QBZkXhe9LMI6A+SZgwhDkB/Vadr5nE7Y nfKK/pQWNHOEEwjVqAdflBsKsIbHecbwELZPz8qrZhMpWYihAGzW9CpN1CmkUltz4fIm UK7XJwK/o480bEuxF/mmtmfnI/S/fQQq5R8IEBlqamRtUeLGHrXTLCKVIiTMlpKxo+RH bag+x2vwD/ioK+s3JrPU/F2LuuPAohfwa/nLAGRxC6kJt+DWD4q7b0bJCeFvfj6tagPQ 51Lsd3nPqS3u4G+SAu1YD/fK+W3xELjFN201q5SgSrS0981Q4A7gv35O5+HVy94omo/K rAAA== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=5t3tzqXqpNbdKtPEsmdz9Dwf6r6pNTpWJhNvYjQG3h4=; b=LsKxqFcF8/OU9yrRm1VZW7Ej3/GCdG5LdlOWVCAEdqx7JLSnozcrJz6zWOH4Uz0pxx RyJUQHPDgI1zWpleIsbbUe+CDwyZip78B8Vw/IHXkd/oCzeGAx4WeyrIcgV5BWsnWvzx Ak0PISvSLvmx7I+1FnVhKePnslpHGbZv5g1+wwjWs1tmrObhvDNJ4UCAh4hmfopnSeSb W2vaiHkvetd6Mmg8Jr3L0qwhg7ZGF0/XGFkvkOt7CgMxTAicHJrbKCWrW/j3mPrLjqd2 52Z5247YGF9RhcPGBqPt4T9z7Ilm1MCLEEtme94CEK1tvEw0ZYO2AR48phlOnZJtMwtM X/zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b="A8/G7jLp"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 v20si5226867pjn.27.2019.08.01.16.19.42; Thu, 01 Aug 2019 16:19:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b="A8/G7jLp"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388480AbfHATQY (ORCPT + 99 others); Thu, 1 Aug 2019 15:16:24 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:44409 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbfHATQY (ORCPT ); Thu, 1 Aug 2019 15:16:24 -0400 Received: by mail-qk1-f196.google.com with SMTP id d79so52876123qke.11 for ; Thu, 01 Aug 2019 12:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=5t3tzqXqpNbdKtPEsmdz9Dwf6r6pNTpWJhNvYjQG3h4=; b=A8/G7jLpfTgWadsEuB/dl0+Z3G3BWFlweQBVY1yMVtyNgidSuRKVOD5NLpfvbzBoQl Jxg6iXbYPCsTP7otqAHyNwF+tG3vwKTo2Nn7xzSAHpDS0Q/XMRNZuwJ7hlq4DtT+7R0O RtOF5zxB6zAo28I7gSVJsacqmeJ/bUlChSE1raHV6axfUoBIPrDJH0sWABXqS0odxz7r lJTEGA4UnGeuLdxwkP54y154QbH4j5pwN7I5eH6SyZwM1pnPmBWiUXpjU50JfMGhL7hF BvhAapZSg0WnouNpqVkx+bYXXWNTyGvL9UOwrlrtTJPaaz2BSdhsnTlUH+ZBI+2zXJ/A TozA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=5t3tzqXqpNbdKtPEsmdz9Dwf6r6pNTpWJhNvYjQG3h4=; b=iYtTQEkhgTiLeWD3+jCbxhEe1aEv/FWeqMPM32QghTZ1hJto8jM87CjsNUkMYgz0Lt 4HcD5LdVqS0JeKY7cBnvqkHjD+p090syKvEOsnVrVtUFxZEWrRDver3M4ba7Dr5SgTnr 1PsiSHcyAuZM/tQqh5xTm4P/EtBkWHd0GpLuoFMC/OG011F3DyeP/LAwxKijgEzMSeB/ 5XGF2L8/nd+Z/meCazcC9Mqgb6UmmTD4fYeGnOUaUreUzSHdjvvN6h/WHFkCzFFcE1U9 jq9s36/77Ja7D8EnOeHM9ibIPDq/+rU/PvD2Dfm84Wqh+3mqgN5En92ZRMFq9tmoxYRt uNZQ== X-Gm-Message-State: APjAAAVpfL4oGvYtvpD3U12dmBEXrhL8jgPrH8b7e1Et9z+QloJAZv8D JJfFo/n+swvd/jG01kPrNUPstQ== X-Received: by 2002:a05:620a:1404:: with SMTP id d4mr87089021qkj.228.1564686983047; Thu, 01 Aug 2019 12:16:23 -0700 (PDT) Received: from dhcp-41-57.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id c5sm33070187qkb.41.2019.08.01.12.16.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 12:16:22 -0700 (PDT) Message-ID: <1564686979.11067.48.camel@lca.pw> Subject: Re: [PATCH v2] acpica: fix -Wnull-pointer-arithmetic warnings From: Qian Cai To: "Moore, Robert" , "Wysocki, Rafael J" Cc: "Schmauss, Erik" , "jkim@FreeBSD.org" , "lenb@kernel.org" , "ndesaulniers@google.com" , "linux-acpi@vger.kernel.org" , "devel@acpica.org" , "clang-built-linux@googlegroups.com" , "linux-kernel@vger.kernel.org" Date: Thu, 01 Aug 2019 15:16:19 -0400 In-Reply-To: <94F2FBAB4432B54E8AACC7DFDE6C92E3B9661CBD@ORSMSX110.amr.corp.intel.com> References: <20190718194846.1880-1-cai@lca.pw> <94F2FBAB4432B54E8AACC7DFDE6C92E3B9661CBD@ORSMSX110.amr.corp.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-10.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-07-26 at 19:35 +0000, Moore, Robert wrote: > We've taken the change to ACPI_TO_POINTER. I am a bit confused here. I saw the commit in the acpia repo. https://github.com/acpica/acpica/commit/02bbca5070e42d298c9b824300aa0eb8a082d797 but how does that change will go into the linux kernel? Suppose Rafael will need to pick it up manually? > > > -----Original Message----- > From: Qian Cai [mailto:cai@lca.pw]  > Sent: Thursday, July 18, 2019 12:49 PM > To: Wysocki, Rafael J > Cc: Moore, Robert ; Schmauss, Erik l.com>; jkim@FreeBSD.org; lenb@kernel.org; ndesaulniers@google.com; linux-acpi > @vger.kernel.org; devel@acpica.org; clang-built-linux@googlegroups.com; linux- > kernel@vger.kernel.org; Qian Cai > Subject: [PATCH v2] acpica: fix -Wnull-pointer-arithmetic warnings > > Clang generate quite a few of those warnings. > > drivers/acpi/scan.c:759:28: warning: arithmetic on a null pointer treated as a > cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic] > status = acpi_get_handle(ACPI_ROOT_OBJECT, > obj->string.pointer, >                                          ^~~~~~~~~~~~~~~~ > ./include/acpi/actypes.h:458:56: note: expanded from macro 'ACPI_ROOT_OBJECT' >  #define ACPI_ROOT_OBJECT                ((acpi_handle) ACPI_TO_POINTER > (ACPI_MAX_PTR)) > ^~~~~~~~~~~~~~~ > ./include/acpi/actypes.h:509:41: note: expanded from macro 'ACPI_TO_POINTER' >  #define ACPI_TO_POINTER(i)              ACPI_ADD_PTR (void, (void *) 0, > (acpi_size) (i)) >                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ./include/acpi/actypes.h:503:84: note: expanded from macro 'ACPI_ADD_PTR' >  #define ACPI_ADD_PTR(t, a, b)           ACPI_CAST_PTR (t, > (ACPI_CAST_PTR (u8, (a)) + (acpi_size)(b))) >                                          ^~~~~~~~~~~~~~~~~ > ./include/acpi/actypes.h:501:66: note: expanded from macro 'ACPI_CAST_PTR' >  #define ACPI_CAST_PTR(t, p)             ((t *) (acpi_uintptr_t) (p)) >                                                                  ^ This is > because pointer arithmetic on a pointer not pointing to an array is an > undefined behavior (C11 6.5.6, constraint 8). Fix it by just casting the > corresponding pointers using ACPI_CAST_PTR() and skip the arithmetic. Also, > fix a checkpatch warning together. > > ERROR: Macros with complex values should be enclosed in parentheses >  #45: FILE: include/acpi/actypes.h:509: > +#define ACPI_TO_POINTER(i)              ACPI_CAST_PTR (void, i) > > Signed-off-by: Qian Cai > --- > > v2: Use ACPI_CAST_PTR() in ACPI_TO_POINTER() directly without >     arithmetic. > >  include/acpi/actypes.h | 2 +- >  1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index > ad6892a24015..163181e2d884 100644 > --- a/include/acpi/actypes.h > +++ b/include/acpi/actypes.h > @@ -506,7 +506,7 @@ typedef u64 acpi_integer; >   >  /* Pointer/Integer type conversions */ >   > -#define ACPI_TO_POINTER(i)              ACPI_ADD_PTR (void, (void *) 0, > (acpi_size) (i)) > +#define ACPI_TO_POINTER(i)              (ACPI_CAST_PTR (void, i)) >  #define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p, (void *) 0) >  #define ACPI_OFFSET(d, f)               ACPI_PTR_DIFF (&(((d *) 0)->f), (void > *) 0) >  #define ACPI_PHYSADDR_TO_PTR(i)         ACPI_TO_POINTER(i) > -- > 2.20.1 (Apple Git-117) >