[Intel-gfx] [PATCH] drm/i915/pmu: Hide the (unsigned long)ptr cast
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Fri Nov 24 08:04:28 UTC 2017
On 23/11/2017 17:42, Chris Wilson 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
Why is it even complaining about this? Maybe it is early but I don't see
a problem.
Regards,
Tvrtko
> 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));
> }
>
> #define I915_EVENT_ATTR(_name, _config) \
> diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
> index 8d07764887ec..2595fbf6451f 100644
> --- a/drivers/gpu/drm/i915/i915_utils.h
> +++ b/drivers/gpu/drm/i915/i915_utils.h
> @@ -107,6 +107,11 @@ static inline u64 ptr_to_u64(const void *ptr)
> return (uintptr_t)ptr;
> }
>
> +static inline unsigned long ptr_to_ulong(const void *ptr)
> +{
> + return ptr_to_u64(ptr);
> +}
> +
> #define u64_to_ptr(T, x) ({ \
> typecheck(u64, x); \
> (T *)(uintptr_t)(x); \
>
More information about the Intel-gfx
mailing list