From: "Moore, Robert" <robert.moore@intel.com>
To: Qian Cai <cai@lca.pw>, Nick Desaulniers <ndesaulniers@google.com>
Cc: "Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
"Schmauss, Erik" <erik.schmauss@intel.com>,
"jkim@freebsd.org" <jkim@freebsd.org>,
Len Brown <lenb@kernel.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"devel@acpica.org" <devel@acpica.org>,
clang-built-linux <clang-built-linux@googlegroups.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] acpica: fix -Wnull-pointer-arithmetic warnings
Date: Wed, 24 Jul 2019 14:17:00 +0000 [thread overview]
Message-ID: <94F2FBAB4432B54E8AACC7DFDE6C92E3B96618DB@ORSMSX110.amr.corp.intel.com> (raw)
In-Reply-To: <1563975605.11067.8.camel@lca.pw>
-----Original Message-----
From: Qian Cai [mailto:cai@lca.pw]
Sent: Wednesday, July 24, 2019 6:40 AM
To: Moore, Robert <robert.moore@intel.com>; Nick Desaulniers <ndesaulniers@google.com>
Cc: Wysocki, Rafael J <rafael.j.wysocki@intel.com>; Schmauss, Erik <erik.schmauss@intel.com>; jkim@freebsd.org; Len Brown <lenb@kernel.org>; linux-acpi@vger.kernel.org; devel@acpica.org; clang-built-linux <clang-built-linux@googlegroups.com>; LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] acpica: fix -Wnull-pointer-arithmetic warnings
On Tue, 2019-07-23 at 20:49 +0000, Moore, Robert wrote:
> > > Signed-off-by: Qian Cai <cai@lca.pw>
> > > ---
> > > include/acpi/actypes.h | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index
> > > ad6892a24015..25b4a32da177 100644
> > > --- a/include/acpi/actypes.h
> > > +++ b/include/acpi/actypes.h
> > > @@ -500,13 +500,13 @@ typedef u64 acpi_integer;
> > >
> > > #define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t)
> > > (p)) #define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)
> > > (acpi_uintptr_t) (p)) -#define ACPI_ADD_PTR(t, a, b)
> > > ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_size)(b)))
> > > +#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (a) +
> > > (acpi_size)(b))
>
> We have some questions concerning this change. If (a) is not cast to a
> u8, the addition will be in whatever units are appropriate for (a)
> i.e., the type of (a). However, we want ACPI_ADD_PTR (And
> ACPI_SUB_PTR) to simply perform a byte addition or subtraction - thus
> the cast to u8. I believe that is the original thinking behind the macros.
I posted a v2 a while ago, and should clear this concern.
OK then this change only affects ACPI_TO_POINTER?
+#define ACPI_TO_POINTER(i) ACPI_CAST_PTR (void, i)
>
> > > #define ACPI_SUB_PTR(t, a, b) ACPI_CAST_PTR (t,
> > > (ACPI_CAST_PTR (u8, (a)) - (acpi_size)(b))) #define
> > > ACPI_PTR_DIFF(a, b) ((acpi_size) (ACPI_CAST_PTR (u8,
> > > (a)) - ACPI_CAST_PTR (u8, (b))))
> > >
> > > /* Pointer/Integer type conversions */
> > >
> > > -#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void
> > > *) 0,
> > > (acpi_size) (i))
> > > +#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, 0,
> > > (acpi_size) (i))
> >
> > IIUC, these are adding `i` to NULL (or (void*)0)? X + 0 == X ?
> > --
> > Thanks,
> > ~Nick Desaulniers
>
>
next prev parent reply other threads:[~2019-07-24 14:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-17 3:38 [PATCH] acpica: fix -Wnull-pointer-arithmetic warnings Qian Cai
2019-07-17 22:01 ` Nick Desaulniers
2019-07-18 0:49 ` Qian Cai
2019-07-23 20:49 ` Moore, Robert
2019-07-24 13:40 ` Qian Cai
2019-07-24 14:17 ` Moore, Robert [this message]
2019-07-24 14:39 ` Qian Cai
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=94F2FBAB4432B54E8AACC7DFDE6C92E3B96618DB@ORSMSX110.amr.corp.intel.com \
--to=robert.moore@intel.com \
--cc=cai@lca.pw \
--cc=clang-built-linux@googlegroups.com \
--cc=devel@acpica.org \
--cc=erik.schmauss@intel.com \
--cc=jkim@freebsd.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ndesaulniers@google.com \
--cc=rafael.j.wysocki@intel.com \
/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).