DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/virtio-user: fix implicit int to enum conversion
@ 2016-06-23  7:40 Jianfeng Tan
  2016-06-23 20:51 ` Stephen Hemminger
  2016-06-26 13:48 ` [dpdk-dev] [PATCH v2] " Jianfeng Tan
  0 siblings, 2 replies; 5+ messages in thread
From: Jianfeng Tan @ 2016-06-23  7:40 UTC (permalink / raw)
  To: dev; +Cc: yuanhan.liu, huawei.xie, Jianfeng Tan

Implicit int to enum conversion is not allowed when icc is used as
the compiler. It raises the compiling error like,
    /.../dpdk/drivers/net/virtio/virtio_user/vhost_user.c(257):
        error #188: enumerated type mixed with another type
  	msg.request = req;
  	            ^

The fix is simple, aka make such conversion explicit.

Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 drivers/net/virtio/virtio_user/vhost_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index 95e80f8..e2772d5 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -254,7 +254,7 @@ vhost_user_sock(int vhostfd, uint64_t req, void *arg)
 
 	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
 
-	msg.request = req;
+	msg.request = (enum vhost_user_request)req;
 	msg.flags = VHOST_USER_VERSION;
 	msg.size = 0;
 
-- 
2.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] net/virtio-user: fix implicit int to enum conversion
  2016-06-23  7:40 [dpdk-dev] [PATCH] net/virtio-user: fix implicit int to enum conversion Jianfeng Tan
@ 2016-06-23 20:51 ` Stephen Hemminger
  2016-06-24  0:51   ` Tan, Jianfeng
  2016-06-26 13:48 ` [dpdk-dev] [PATCH v2] " Jianfeng Tan
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2016-06-23 20:51 UTC (permalink / raw)
  To: Jianfeng Tan; +Cc: dev, yuanhan.liu, huawei.xie

On Thu, 23 Jun 2016 07:40:20 +0000
Jianfeng Tan <jianfeng.tan@intel.com> wrote:

> Implicit int to enum conversion is not allowed when icc is used as
> the compiler. It raises the compiling error like,
>     /.../dpdk/drivers/net/virtio/virtio_user/vhost_user.c(257):
>         error #188: enumerated type mixed with another type
>   	msg.request = req;
>   	            ^
> 
> The fix is simple, aka make such conversion explicit.
> 
> Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>  drivers/net/virtio/virtio_user/vhost_user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
> index 95e80f8..e2772d5 100644
> --- a/drivers/net/virtio/virtio_user/vhost_user.c
> +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> @@ -254,7 +254,7 @@ vhost_user_sock(int vhostfd, uint64_t req, void *arg)
>  
>  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
>  
> -	msg.request = req;
> +	msg.request = (enum vhost_user_request)req;
>  	msg.flags = VHOST_USER_VERSION;
>  	msg.size = 0;
>  

Why not just just change API, to use enum? This would move type checking
out to the user.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] net/virtio-user: fix implicit int to enum conversion
  2016-06-23 20:51 ` Stephen Hemminger
@ 2016-06-24  0:51   ` Tan, Jianfeng
  0 siblings, 0 replies; 5+ messages in thread
From: Tan, Jianfeng @ 2016-06-24  0:51 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, yuanhan.liu, Xie, Huawei

Hi Stephen,

> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Friday, June 24, 2016 4:51 AM
> To: Tan, Jianfeng
> Cc: dev@dpdk.org; yuanhan.liu@linux.intel.com; Xie, Huawei
> Subject: Re: [dpdk-dev] [PATCH] net/virtio-user: fix implicit int to enum
> conversion
> 
> On Thu, 23 Jun 2016 07:40:20 +0000
> Jianfeng Tan <jianfeng.tan@intel.com> wrote:
> 
> > Implicit int to enum conversion is not allowed when icc is used as
> > the compiler. It raises the compiling error like,
> >     /.../dpdk/drivers/net/virtio/virtio_user/vhost_user.c(257):
> >         error #188: enumerated type mixed with another type
> >   	msg.request = req;
> >   	            ^
> >
> > The fix is simple, aka make such conversion explicit.
> >
> > Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
> >
> > Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> > ---
> >  drivers/net/virtio/virtio_user/vhost_user.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> b/drivers/net/virtio/virtio_user/vhost_user.c
> > index 95e80f8..e2772d5 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_user.c
> > +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> > @@ -254,7 +254,7 @@ vhost_user_sock(int vhostfd, uint64_t req, void
> *arg)
> >
> >  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
> >
> > -	msg.request = req;
> > +	msg.request = (enum vhost_user_request)req;
> >  	msg.flags = VHOST_USER_VERSION;
> >  	msg.size = 0;
> >
> 
> Why not just just change API, to use enum? This would move type checking
> out to the user.

The history reason to do this is to adapt both vhost-user and vhost-net request. But yes, now we only have vhost-user supported, I'll change to use enum instead of uint64_t as the type of req.

Thank you for suggestion!

Thanks,
Jianfeng

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v2] net/virtio-user: fix implicit int to enum conversion
  2016-06-23  7:40 [dpdk-dev] [PATCH] net/virtio-user: fix implicit int to enum conversion Jianfeng Tan
  2016-06-23 20:51 ` Stephen Hemminger
@ 2016-06-26 13:48 ` Jianfeng Tan
  2016-06-30  5:28   ` Yuanhan Liu
  1 sibling, 1 reply; 5+ messages in thread
From: Jianfeng Tan @ 2016-06-26 13:48 UTC (permalink / raw)
  To: dev; +Cc: yuanhan.liu, huawei.xie, stephen, Jianfeng Tan

Implicit int to enum conversion is not allowed when icc is used as
the compiler. It raises the compiling error like,
    /.../dpdk/drivers/net/virtio/virtio_user/vhost_user.c(257):
        error #188: enumerated type mixed with another type
  	msg.request = req;
  	            ^

The fix is simple, change the type of parameter req to enum
vhost_user_request.

Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")

Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 drivers/net/virtio/virtio_user/vhost.h      | 2 +-
 drivers/net/virtio/virtio_user/vhost_user.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost.h b/drivers/net/virtio/virtio_user/vhost.h
index 897042f..7adb55f 100644
--- a/drivers/net/virtio/virtio_user/vhost.h
+++ b/drivers/net/virtio/virtio_user/vhost.h
@@ -139,7 +139,7 @@ struct vhost_user_msg {
 #define VHOST_USER_F_PROTOCOL_FEATURES 30
 #define VHOST_USER_MQ (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)
 
-int vhost_user_sock(int vhostfd, uint64_t req, void *arg);
+int vhost_user_sock(int vhostfd, enum vhost_user_request req, void *arg);
 int vhost_user_setup(const char *path);
 int vhost_user_enable_queue_pair(int vhostfd, uint16_t pair_idx, int enable);
 
diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index 95e80f8..a2b0687 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -240,7 +240,7 @@ static const char * const vhost_msg_strings[] = {
 };
 
 int
-vhost_user_sock(int vhostfd, uint64_t req, void *arg)
+vhost_user_sock(int vhostfd, enum vhost_user_request req, void *arg)
 {
 	struct vhost_user_msg msg;
 	struct vhost_vring_file *file = 0;
-- 
2.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio-user: fix implicit int to enum conversion
  2016-06-26 13:48 ` [dpdk-dev] [PATCH v2] " Jianfeng Tan
@ 2016-06-30  5:28   ` Yuanhan Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Yuanhan Liu @ 2016-06-30  5:28 UTC (permalink / raw)
  To: Jianfeng Tan; +Cc: dev, huawei.xie, stephen

On Sun, Jun 26, 2016 at 01:48:13PM +0000, Jianfeng Tan wrote:
> Implicit int to enum conversion is not allowed when icc is used as
> the compiler. It raises the compiling error like,
>     /.../dpdk/drivers/net/virtio/virtio_user/vhost_user.c(257):
>         error #188: enumerated type mixed with another type
>   	msg.request = req;
>   	            ^
> 
> The fix is simple, change the type of parameter req to enum
> vhost_user_request.
> 
> Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
> 
> Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>

Applied to dpdk-next-virtio, with the title changed to:

    net/virtio-user: fix build error with icc

Thanks.

	--yliu

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-30  5:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-23  7:40 [dpdk-dev] [PATCH] net/virtio-user: fix implicit int to enum conversion Jianfeng Tan
2016-06-23 20:51 ` Stephen Hemminger
2016-06-24  0:51   ` Tan, Jianfeng
2016-06-26 13:48 ` [dpdk-dev] [PATCH v2] " Jianfeng Tan
2016-06-30  5:28   ` Yuanhan Liu

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).