From patchwork Tue Mar 8 07:52:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 593915 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EC2D8140783 for ; Tue, 8 Mar 2016 18:55:12 +1100 (AEDT) Received: from localhost ([::1]:32821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adCU3-00005X-2S for incoming@patchwork.ozlabs.org; Tue, 08 Mar 2016 02:55:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adCSE-00053n-2x for qemu-devel@nongnu.org; Tue, 08 Mar 2016 02:53:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adCSA-0000Bp-Qf for qemu-devel@nongnu.org; Tue, 08 Mar 2016 02:53:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adCSA-0000Bl-LU for qemu-devel@nongnu.org; Tue, 08 Mar 2016 02:53:14 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 414BD64373; Tue, 8 Mar 2016 07:53:14 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (vpn1-5-240.pek2.redhat.com [10.72.5.240]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u287qkMa010527; Tue, 8 Mar 2016 02:53:10 -0500 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 8 Mar 2016 15:52:36 +0800 Message-Id: <1457423564-9724-5-git-send-email-jasowang@redhat.com> In-Reply-To: <1457423564-9724-1-git-send-email-jasowang@redhat.com> References: <1457423564-9724-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 08 Mar 2016 07:53:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Jason Wang Subject: [Qemu-devel] [PULL V2 04/12] net: simplify net_init_tap_one logic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paolo Bonzini net_init_tap_one receives in vhostfdname a fd name from vhostfd= or vhostfds=, or NULL if there is no vhostfd=/vhostfds=. It is simpler to just check vhostfdname, than it is to check for vhostfd= or vhostfds=. This also calms down Coverity, which otherwise thinks that monitor_fd_param could dereference a NULL vhostfdname. Signed-off-by: Paolo Bonzini Signed-off-by: Jason Wang --- net/tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tap.c b/net/tap.c index cfb6831..cd7a7fc 100644 --- a/net/tap.c +++ b/net/tap.c @@ -662,7 +662,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, options.backend_type = VHOST_BACKEND_TYPE_KERNEL; options.net_backend = &s->nc; - if (tap->has_vhostfd || tap->has_vhostfds) { + if (vhostfdname) { vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err); if (vhostfd == -1) { error_propagate(errp, err); @@ -684,7 +684,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, "vhost-net requested but could not be initialized"); return; } - } else if (tap->has_vhostfd || tap->has_vhostfds) { + } else if (vhostfdname) { error_setg(errp, "vhostfd= is not valid without vhost"); } }