From: Erik Schmauss <erik.schmauss@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Jung-uk Kim <jkim@FreeBSD.org>, Jung-uk Kim <jkim@free_BSD.org>,
Erik Schmauss <erik.schmauss@intel.com>
Subject: [PATCH 2/6] ACPICA: Avoid NULL pointer arithmetic
Date: Wed, 24 Jan 2018 15:42:30 -0800 [thread overview]
Message-ID: <20180124234234.19828-3-erik.schmauss@intel.com> (raw)
In-Reply-To: <20180124234234.19828-1-erik.schmauss@intel.com>
From: Jung-uk Kim <jkim@FreeBSD.org>
We should not assume NULL is defined as "(void *)0" because NULL is
an implementation-defined macro. Especially, Clang 6 complains about
it, i.e., "arithmetic on a null pointer treated as a cast from integer
to pointer is a GNU extension".
Signed-off-by: Jung-uk Kim <jkim@free_BSD.org>
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
---
include/acpi/actypes.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 31f1be74dd16..f3999ae7a43f 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -485,7 +485,7 @@ typedef u8 acpi_owner_id;
/*
* Constants with special meanings
*/
-#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (acpi_handle, NULL, ACPI_MAX_PTR)
+#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (acpi_handle, (void *) 0, ACPI_MAX_PTR)
#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */
#define ACPI_DO_NOT_WAIT 0
@@ -536,9 +536,9 @@ typedef u64 acpi_integer;
/* Pointer/Integer type conversions */
-#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(acpi_size) i)
-#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL)
-#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) NULL)
+#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) 0, (acpi_size) (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)
#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
--
2.14.3
next prev parent reply other threads:[~2018-01-24 23:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-24 23:42 [PATCH 0/6] ACPICA version 20180105 Erik Schmauss
2018-01-24 23:42 ` [PATCH 1/6] ACPICA: Linux: add support for X32 ABI compilation Erik Schmauss
2018-01-24 23:42 ` Erik Schmauss [this message]
2018-01-24 23:42 ` [PATCH 3/6] ACPICA: Prefer ACPI_TO_POINTER() over ACPI_ADD_PTR() Erik Schmauss
2018-01-24 23:42 ` [PATCH 4/6] ACPICA: Add a missing pair of parentheses Erik Schmauss
2018-01-24 23:42 ` [PATCH 6/6] ACPICA: Update version to 20180105 Erik Schmauss
2018-02-04 8:00 ` [PATCH 0/6] ACPICA version 20180105 Rafael J. Wysocki
2018-02-08 9:40 ` Rafael J. Wysocki
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=20180124234234.19828-3-erik.schmauss@intel.com \
--to=erik.schmauss@intel.com \
--cc=jkim@FreeBSD.org \
--cc=jkim@free_BSD.org \
--cc=linux-acpi@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).