2019-07-10 14:30:38

by Pankaj Gupta

[permalink] [raw]
Subject: [PATCH] virtio_pmem: fix sparse warning

This patch fixes below sparse warning related to __virtio
type in virtio pmem driver. This is reported by Intel test
bot on linux-next tree.

nd_virtio.c:56:28: warning: incorrect type in assignment (different base types)
nd_virtio.c:56:28: expected unsigned int [unsigned] [usertype] type
nd_virtio.c:56:28: got restricted __virtio32
nd_virtio.c:93:59: warning: incorrect type in argument 2 (different base types)
nd_virtio.c:93:59: expected restricted __virtio32 [usertype] val
nd_virtio.c:93:59: got unsigned int [unsigned] [usertype] ret

Signed-off-by: Pankaj Gupta <[email protected]>
Reported-by: kbuild test robot <[email protected]>
---

This fixes a warning, so submitting it as a separate
patch on top of virtio pmem series.

include/uapi/linux/virtio_pmem.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/virtio_pmem.h b/include/uapi/linux/virtio_pmem.h
index efcd72f2d20d..f89129bf1f84 100644
--- a/include/uapi/linux/virtio_pmem.h
+++ b/include/uapi/linux/virtio_pmem.h
@@ -23,12 +23,12 @@ struct virtio_pmem_config {

struct virtio_pmem_resp {
/* Host return status corresponding to flush request */
- __u32 ret;
+ __virtio32 ret;
};

struct virtio_pmem_req {
/* command type */
- __u32 type;
+ __virtio32 type;
};

#endif
--
2.20.1


2019-07-11 18:22:07

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH] virtio_pmem: fix sparse warning

On Wed, Jul 10, 2019 at 07:57:00PM +0530, Pankaj Gupta wrote:
> This patch fixes below sparse warning related to __virtio
> type in virtio pmem driver. This is reported by Intel test
> bot on linux-next tree.
>
> nd_virtio.c:56:28: warning: incorrect type in assignment (different base types)
> nd_virtio.c:56:28: expected unsigned int [unsigned] [usertype] type
> nd_virtio.c:56:28: got restricted __virtio32
> nd_virtio.c:93:59: warning: incorrect type in argument 2 (different base types)
> nd_virtio.c:93:59: expected restricted __virtio32 [usertype] val
> nd_virtio.c:93:59: got unsigned int [unsigned] [usertype] ret
>
> Signed-off-by: Pankaj Gupta <[email protected]>
> Reported-by: kbuild test robot <[email protected]>
> ---
>
> This fixes a warning, so submitting it as a separate
> patch on top of virtio pmem series.
>
> include/uapi/linux/virtio_pmem.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/linux/virtio_pmem.h b/include/uapi/linux/virtio_pmem.h
> index efcd72f2d20d..f89129bf1f84 100644
> --- a/include/uapi/linux/virtio_pmem.h
> +++ b/include/uapi/linux/virtio_pmem.h
> @@ -23,12 +23,12 @@ struct virtio_pmem_config {
>
> struct virtio_pmem_resp {
> /* Host return status corresponding to flush request */
> - __u32 ret;
> + __virtio32 ret;
> };
>
> struct virtio_pmem_req {
> /* command type */
> - __u32 type;
> + __virtio32 type;
> };
>
> #endif

req/resp are in memory right?
Then this looks like a wrong fix.
The accessors should all use cpu_to/from_le
and they types should be __le32.

> --
> 2.20.1

2019-07-11 19:11:36

by Pankaj Gupta

[permalink] [raw]
Subject: Re: [PATCH] virtio_pmem: fix sparse warning



>
> On Wed, Jul 10, 2019 at 07:57:00PM +0530, Pankaj Gupta wrote:
> > This patch fixes below sparse warning related to __virtio
> > type in virtio pmem driver. This is reported by Intel test
> > bot on linux-next tree.
> >
> > nd_virtio.c:56:28: warning: incorrect type in assignment (different base
> > types)
> > nd_virtio.c:56:28: expected unsigned int [unsigned] [usertype] type
> > nd_virtio.c:56:28: got restricted __virtio32
> > nd_virtio.c:93:59: warning: incorrect type in argument 2 (different base
> > types)
> > nd_virtio.c:93:59: expected restricted __virtio32 [usertype] val
> > nd_virtio.c:93:59: got unsigned int [unsigned] [usertype] ret
> >
> > Signed-off-by: Pankaj Gupta <[email protected]>
> > Reported-by: kbuild test robot <[email protected]>
> > ---
> >
> > This fixes a warning, so submitting it as a separate
> > patch on top of virtio pmem series.
> >
> > include/uapi/linux/virtio_pmem.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/uapi/linux/virtio_pmem.h
> > b/include/uapi/linux/virtio_pmem.h
> > index efcd72f2d20d..f89129bf1f84 100644
> > --- a/include/uapi/linux/virtio_pmem.h
> > +++ b/include/uapi/linux/virtio_pmem.h
> > @@ -23,12 +23,12 @@ struct virtio_pmem_config {
> >
> > struct virtio_pmem_resp {
> > /* Host return status corresponding to flush request */
> > - __u32 ret;
> > + __virtio32 ret;
> > };
> >
> > struct virtio_pmem_req {
> > /* command type */
> > - __u32 type;
> > + __virtio32 type;
> > };
> >
> > #endif
>
> req/resp are in memory right?
> Then this looks like a wrong fix.
> The accessors should all use cpu_to/from_le
> and they types should be __le32.

o.k

>
> > --
> > 2.20.1
>