[Intel-gfx] [PATCH] drm/i915/pmu: Hide the (unsigned long)ptr cast
Chris Wilson
chris at chris-wilson.co.uk
Thu Nov 23 20:58:04 UTC 2017
Quoting Michal Wajdeczko (2017-11-23 18:20:52)
> On Thu, 23 Nov 2017 18:42:13 +0100, Chris Wilson
> <chris at chris-wilson.co.uk> wrote:
>
> > We pretend the PMU config id is a pointer value when encoding it into
> > the device parameters for presentation via sysfs. This requires casting
> > of an unsigned long into and out of the pointer member, which annoys
> > smatch:
> >
> > drivers/gpu/drm/i915/i915_pmu.c:684 i915_pmu_event_show() warn: argument
> > 3 to %lx specifier is cast from pointer
> >
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> > ---
> > drivers/gpu/drm/i915/i915_pmu.c | 2 +-
> > drivers/gpu/drm/i915/i915_utils.h | 5 +++++
> > 2 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_pmu.c
> > b/drivers/gpu/drm/i915/i915_pmu.c
> > index 6a42e7f7967d..a8816d25a77b 100644
> > --- a/drivers/gpu/drm/i915/i915_pmu.c
> > +++ b/drivers/gpu/drm/i915/i915_pmu.c
> > @@ -681,7 +681,7 @@ static ssize_t i915_pmu_event_show(struct device
> > *dev,
> > struct dev_ext_attribute *eattr;
> > eattr = container_of(attr, struct dev_ext_attribute, attr);
> > - return sprintf(buf, "config=0x%lx\n", (unsigned long)eattr->var);
> > + return sprintf(buf, "config=0x%lx\n", ptr_to_ulong(eattr->var));
>
> Hmm, can't we just use %p here ?
We could but "%p" raises eyebrows as to leaking kernel addresses. It
would be nicer if there was a integer attribute we could use instead. If
push came to shove, we could just define our own, I believe.
-Chris
More information about the Intel-gfx
mailing list