From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQ9nt-0008Eq-HY for qemu-devel@nongnu.org; Thu, 21 Jul 2016 04:58:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQ9ns-0007JY-Qj for qemu-devel@nongnu.org; Thu, 21 Jul 2016 04:58:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQ9ns-0007JP-Kq for qemu-devel@nongnu.org; Thu, 21 Jul 2016 04:58:00 -0400 From: marcandre.lureau@redhat.com Date: Thu, 21 Jul 2016 12:57:21 +0400 Message-Id: <20160721085750.30008-3-marcandre.lureau@redhat.com> In-Reply-To: <20160721085750.30008-1-marcandre.lureau@redhat.com> References: <20160721085750.30008-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v5 02/31] vhost-user: minor simplification List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mukawa@igel.co.jp, yuanhan.liu@linux.intel.com, victork@redhat.com, jonshin@cisco.com, mst@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau Shorten the code and make it more clear by using the specialized function g_str_has_prefix(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- net/vhost-user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/vhost-user.c b/net/vhost-user.c index c4d63e0..2af212b 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -316,7 +316,6 @@ static int net_vhost_check_net(void *opaque, QemuOpts= *opts, Error **errp) { const char *name =3D opaque; const char *driver, *netdev; - const char virtio_name[] =3D "virtio-net-"; =20 driver =3D qemu_opt_get(opts, "driver"); netdev =3D qemu_opt_get(opts, "netdev"); @@ -326,7 +325,7 @@ static int net_vhost_check_net(void *opaque, QemuOpts= *opts, Error **errp) } =20 if (strcmp(netdev, name) =3D=3D 0 && - strncmp(driver, virtio_name, strlen(virtio_name)) !=3D 0) { + !g_str_has_prefix(driver, "virtio-net-")) { error_setg(errp, "vhost-user requires frontend driver virtio-net= -*"); return -1; } --=20 2.9.0