From nobody Thu Apr 25 18:06:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641820397; cv=none; d=zohomail.com; s=zohoarc; b=mUe75MQe3772mbywr74p2yZp/7Ma6QIePZfOYHElWgBIzyrslPFzSqntWSEcrP2JQ5fnQEJE7NnvFgsDvK5j+fZi9M7tHiATPB73Z0lnqCFaKZEL0y1JqZTPgTtvQgcXLYt17UfRNtxAXN1hGtNWfghhj2rmntGSs3OE70ku1DY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641820397; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lAmEL4unsTGxzR4gDA6FPskTLM5vgeVHg254Egd3SzM=; b=dmwmrF9r+H0krjv3DjrbHRpgB6y1vhuwQZBfMGMjS3sqixB+tKcLnLLrShZUx6BQ7pfBEoheYrT1pPx3qWOYabRPvIhlS1m3cS/UvhGLZoG5ZwgeEgpxTEJuE+n4cus44hFyibsmS+iQSvnaiK4WkfEUhmZ3E+WzTDaP2vQxf7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 164182039737721.153370914797847; Mon, 10 Jan 2022 05:13:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-600-Y9ipzJ6FNa-bm8SwwsLR3w-1; Mon, 10 Jan 2022 08:13:13 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B94F9593A8; Mon, 10 Jan 2022 13:13:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2C1122DEE; Mon, 10 Jan 2022 13:13:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CFAA31809CB8; Mon, 10 Jan 2022 13:13:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20ADD3PI005897 for ; Mon, 10 Jan 2022 08:13:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6E24F22E13; Mon, 10 Jan 2022 13:13:03 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E51A22DEE for ; Mon, 10 Jan 2022 13:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641820396; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lAmEL4unsTGxzR4gDA6FPskTLM5vgeVHg254Egd3SzM=; b=CC2fdllCuuQgYhttqmR3GD6Bn1q2/EQn5/mrtz11gRwdmdTWGYMEXdTYY3xfXpD6KkSyGK 39EgP02TJc8utO5o9+LgMIMJTDsbv7GUcp4FDg2u/hWWCOxArY8eEmHVAUGPvYkMiRaFhM lKoJT/xVm8AMQ9kANe7XPsKLNfF+W2Q= X-MC-Unique: Y9ipzJ6FNa-bm8SwwsLR3w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virsh-network: Don't check for virshXXXTypeFromString() >= VIR_XXX_LAST Date: Mon, 10 Jan 2022 14:12:55 +0100 Message-Id: <8f4d1d9fcc7c1f46ec7717fe8bb13efef033685e.1641820375.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641820398121100001 Content-Type: text/plain; charset="utf-8" They way our VIR_ENUM_IMPL() and virXXXTypeFromString() work is that for any string that's not recognized a negative one is returned. And, since VIR_XXX_LAST is passed to VIR_ENUM_IMPL() we can be sure that all enum members are covered. Therefore, there is no way that virXXXTypeFromString() can return a value that's bigger or equal to VIR_XXX_LAST. I've noticed two places where such comparison was made, both in cmdNetworkUpdate(). Drop them. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- tools/virsh-network.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 5f574be78c..b2daf31d6b 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -984,7 +984,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) command =3D VIR_NETWORK_UPDATE_COMMAND_ADD_LAST; } else { command =3D virshNetworkUpdateCommandTypeFromString(commandStr); - if (command <=3D 0 || command >=3D VIR_NETWORK_UPDATE_COMMAND_LAST= ) { + if (command <=3D 0) { vshError(ctl, _("unrecognized command name '%s'"), commandStr); goto cleanup; } @@ -994,7 +994,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) goto cleanup; =20 section =3D virshNetworkSectionTypeFromString(sectionStr); - if (section <=3D 0 || section >=3D VIR_NETWORK_SECTION_LAST) { + if (section <=3D 0) { vshError(ctl, _("unrecognized section name '%s'"), sectionStr); goto cleanup; } --=20 2.34.1