Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1547320 > unrolled thread

[PATCH 1/1] drm/i915/gvt: verify functions types in new_mmio_info()

Started byNicolas Iooss <nicolas.iooss_linux@m4x.org>
First post2016-12-26 15:00 +0100
Last post2016-12-27 04:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] drm/i915/gvt: verify functions types in new_mmio_info() Nicolas Iooss <nicolas.iooss_linux@m4x.org> - 2016-12-26 15:00 +0100
    Re: [igvt-g-dev] [PATCH 1/1] drm/i915/gvt: verify functions types in  new_mmio_info() Zhenyu Wang <zhenyuw@linux.intel.com> - 2016-12-27 04:00 +0100

#1547320 — [PATCH 1/1] drm/i915/gvt: verify functions types in new_mmio_info()

FromNicolas Iooss <nicolas.iooss_linux@m4x.org>
Date2016-12-26 15:00 +0100
Subject[PATCH 1/1] drm/i915/gvt: verify functions types in new_mmio_info()
Message-ID<sSDYJ-5tQ-5@gated-at.bofh.it>
The current prototype of new_mmio_info() uses void* for parameters read
and write, which are functions with precise calling conventions
(argument types and return type). Write down these conventions in
new_mmio_info() definition.

This has been reported by the following warnings when clang is used to
build the kernel:

    drivers/gpu/drm/i915/gvt/handlers.c:124:21: error: pointer type
    mismatch ('void *' and 'int (*)(struct intel_vgpu *, unsigned int,
    void *, unsigned int)') [-Werror,-Wpointer-type-mismatch]
            info->read = read ? read : intel_vgpu_default_mmio_read;
                              ^ ~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/gpu/drm/i915/gvt/handlers.c:125:23: error: pointer type
    mismatch ('void *' and 'int (*)(struct intel_vgpu *, unsigned int,
    void *, unsigned int)') [-Werror,-Wpointer-type-mismatch]
            info->write = write ? write : intel_vgpu_default_mmio_write;
                                ^ ~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This allows the compiler to detect that sbi_ctl_mmio_write() returns a
"bool" value instead of an expected "int" one. Fix this.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
---
 drivers/gpu/drm/i915/gvt/handlers.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
index 522809710312..052e57124c0a 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -93,7 +93,8 @@ static void write_vreg(struct intel_vgpu *vgpu, unsigned int offset,
 static int new_mmio_info(struct intel_gvt *gvt,
 		u32 offset, u32 flags, u32 size,
 		u32 addr_mask, u32 ro_mask, u32 device,
-		void *read, void *write)
+		int (*read)(struct intel_vgpu *, unsigned int, void *, unsigned int),
+		int (*write)(struct intel_vgpu *, unsigned int, void *, unsigned int))
 {
 	struct intel_gvt_mmio_info *info, *p;
 	u32 start, end, i;
@@ -974,7 +975,7 @@ static int sbi_data_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
 	return 0;
 }
 
-static bool sbi_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
+static int sbi_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
 		void *p_data, unsigned int bytes)
 {
 	u32 data;
-- 
2.11.0

[toc] | [next] | [standalone]


#1547473 — Re: [igvt-g-dev] [PATCH 1/1] drm/i915/gvt: verify functions types in new_mmio_info()

FromZhenyu Wang <zhenyuw@linux.intel.com>
Date2016-12-27 04:00 +0100
SubjectRe: [igvt-g-dev] [PATCH 1/1] drm/i915/gvt: verify functions types in new_mmio_info()
Message-ID<sSQ9z-4CO-1@gated-at.bofh.it>
In reply to#1547320

[Multipart message — attachments visible in raw view] — view raw

On 2016.12.26 14:52:23 +0100, Nicolas Iooss wrote:
> The current prototype of new_mmio_info() uses void* for parameters read
> and write, which are functions with precise calling conventions
> (argument types and return type). Write down these conventions in
> new_mmio_info() definition.
> 
> This has been reported by the following warnings when clang is used to
> build the kernel:
> 
>     drivers/gpu/drm/i915/gvt/handlers.c:124:21: error: pointer type
>     mismatch ('void *' and 'int (*)(struct intel_vgpu *, unsigned int,
>     void *, unsigned int)') [-Werror,-Wpointer-type-mismatch]
>             info->read = read ? read : intel_vgpu_default_mmio_read;
>                               ^ ~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/gpu/drm/i915/gvt/handlers.c:125:23: error: pointer type
>     mismatch ('void *' and 'int (*)(struct intel_vgpu *, unsigned int,
>     void *, unsigned int)') [-Werror,-Wpointer-type-mismatch]
>             info->write = write ? write : intel_vgpu_default_mmio_write;
>                                 ^ ~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> This allows the compiler to detect that sbi_ctl_mmio_write() returns a
> "bool" value instead of an expected "int" one. Fix this.
>

Looks good to me. Will queue this up. Thanks

> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
> ---
>  drivers/gpu/drm/i915/gvt/handlers.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
> index 522809710312..052e57124c0a 100644
> --- a/drivers/gpu/drm/i915/gvt/handlers.c
> +++ b/drivers/gpu/drm/i915/gvt/handlers.c
> @@ -93,7 +93,8 @@ static void write_vreg(struct intel_vgpu *vgpu, unsigned int offset,
>  static int new_mmio_info(struct intel_gvt *gvt,
>  		u32 offset, u32 flags, u32 size,
>  		u32 addr_mask, u32 ro_mask, u32 device,
> -		void *read, void *write)
> +		int (*read)(struct intel_vgpu *, unsigned int, void *, unsigned int),
> +		int (*write)(struct intel_vgpu *, unsigned int, void *, unsigned int))
>  {
>  	struct intel_gvt_mmio_info *info, *p;
>  	u32 start, end, i;
> @@ -974,7 +975,7 @@ static int sbi_data_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
>  	return 0;
>  }
>  
> -static bool sbi_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
> +static int sbi_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
>  		void *p_data, unsigned int bytes)
>  {
>  	u32 data;
> -- 
> 2.11.0
> 
> _______________________________________________
> igvt-g-dev mailing list
> igvt-g-dev@lists.01.org
> https://lists.01.org/mailman/listinfo/igvt-g-dev

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web