Message ID | 1466667620-67731-1-git-send-email-jianfeng.tan@intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Yuanhan Liu |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D33F7C4C8; Thu, 23 Jun 2016 09:40:49 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id DD2BDC484 for <dev@dpdk.org>; Thu, 23 Jun 2016 09:40:47 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 23 Jun 2016 00:40:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,515,1459839600"; d="scan'208";a="833690481" Received: from dpdk06.sh.intel.com ([10.239.128.225]) by orsmga003.jf.intel.com with ESMTP; 23 Jun 2016 00:40:41 -0700 From: Jianfeng Tan <jianfeng.tan@intel.com> To: dev@dpdk.org Cc: yuanhan.liu@linux.intel.com, huawei.xie@intel.com, Jianfeng Tan <jianfeng.tan@intel.com> Date: Thu, 23 Jun 2016 07:40:20 +0000 Message-Id: <1466667620-67731-1-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] net/virtio-user: fix implicit int to enum conversion X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Jianfeng Tan
June 23, 2016, 7:40 a.m. UTC
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(-)
Comments
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.
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
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;