Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp485328ybi; Fri, 26 Jul 2019 13:13:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzruMiLxpKW5k5V2cCuCGfC7Ibb9I/6BHDWEhryWGJUEQDvpPfaOqACJfJl8O00VpYjP817 X-Received: by 2002:a17:902:e306:: with SMTP id cg6mr98154563plb.263.1564172033276; Fri, 26 Jul 2019 13:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564172033; cv=none; d=google.com; s=arc-20160816; b=bChNRp1NFcy47ZGQeSw+IfK7XSlYZVMUYJmqUFZ28gbMqqQV/5EN1sB3s5PdYM5B9s Vjmpu/FAKYljVelnGrWVZS/oZ3JnapuxZt87i34ofILR9ToYY5Kwzm1OqEpS+mkhxfsS n8Z0Bj8Kbqyf45Y/kRLaUwtclUYhgfQNA/gg0lqPhrbg1B0S/wBouZyZtyY8yL7hvt4B uylYrAXqDCV+r3Vd0NCDKSnoLcmD8UvzHHyQNyaRp66qLsYpPD4OU6EgUa96pIuuZ9AT krisNf9xFzHipNYzMXuhdnZ3dn0o8OwPZ/hY0rUwrgq5ZX0RSTwJbargIRS5u/RWZ4ZN hg2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=OdkbW2ycos6GbYvfpG3rlxsuzIt2Wtvc/QImQPum834=; b=WU7VPmpva7/MJx7bvbkq3vzwg9+D+BFUY4aLDZATrjWx67BHCX6GXn9XaN54fV65OT PsFbk7/QrGYo9kI3rYSkvvPUvk32O6CCSQF9CZapGr6nfM1nMEC8Zh0eQVdJOTTDXx6/ ECRm9R3SjMO0DpX9YHrCj8EaZkuFn26YbZJ6svnO97RpFADNqcSiVQ5FKfcnfe3mP5Bw 8vVH3ADN+geERza0a9l4QPB4cj+pFIRLtCy+ofdb1lOVP/BdIhWbnmE8LJmp++RMF0aV zzuZ7+BJ+vdDghRK6AJfujJkE5ceSVxV3mtKjcIWnGwevjvDmC6Czc+Vzg9otj1Y5WAn c0fg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si21258955pgm.409.2019.07.26.13.13.37; Fri, 26 Jul 2019 13:13:53 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727621AbfGZTfv convert rfc822-to-8bit (ORCPT + 99 others); Fri, 26 Jul 2019 15:35:51 -0400 Received: from mga07.intel.com ([134.134.136.100]:45515 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbfGZTfv (ORCPT ); Fri, 26 Jul 2019 15:35:51 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2019 12:35:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,312,1559545200"; d="scan'208";a="181973736" Received: from orsmsx108.amr.corp.intel.com ([10.22.240.6]) by orsmga002.jf.intel.com with ESMTP; 26 Jul 2019 12:35:50 -0700 Received: from orsmsx161.amr.corp.intel.com (10.22.240.84) by ORSMSX108.amr.corp.intel.com (10.22.240.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 26 Jul 2019 12:35:50 -0700 Received: from orsmsx110.amr.corp.intel.com ([169.254.10.211]) by ORSMSX161.amr.corp.intel.com ([169.254.4.246]) with mapi id 14.03.0439.000; Fri, 26 Jul 2019 12:35:50 -0700 From: "Moore, Robert" To: Qian Cai , "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" Subject: RE: [PATCH v2] acpica: fix -Wnull-pointer-arithmetic warnings Thread-Topic: [PATCH v2] acpica: fix -Wnull-pointer-arithmetic warnings Thread-Index: AQHVPaHylXmfzBauvEybJLDaugeeCqbdV0WA Date: Fri, 26 Jul 2019 19:35:49 +0000 Message-ID: <94F2FBAB4432B54E8AACC7DFDE6C92E3B9661CBD@ORSMSX110.amr.corp.intel.com> References: <20190718194846.1880-1-cai@lca.pw> In-Reply-To: <20190718194846.1880-1-cai@lca.pw> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjJiMzAxZTctOWE5ZS00MjJhLWE4NDAtYzI2NzI2OWNkNGNjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRWo5bWtmaEIrbVlsZUZ3SVNjVVwvR3dsRGdcL2RCa0tId2VMSUZBYndYXC9SdGNzbk1hdTQ2QkFaWHZvV3NocGlhWCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.22.254.139] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We've taken the change to ACPI_TO_POINTER. Thanks, Bob -----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 ; 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)