From nobody Mon Feb 9 03:14:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612448061; cv=none; d=zohomail.com; s=zohoarc; b=lmxWTYYW3+3jiOxdyg/zFFCr+j60oIetZ8cYDdPbRTeyOP4sdxEqpE4SJNpIwWjS4vTDK+qk+fbib6NFUIKOS0QvY0orb7AYe7X4WgQNmBdLWcARJPiDQLxVJaGib4AMIn19/y07XodDURC1aqF0s8f8PS686zvlx/A+IdkuXz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612448061; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NvFFY94GWKHlZU83kg4dnepogD24tgBCtnMR+Y/hTrA=; b=Ld3RQ8xEghHZfXyaa8pUoHwkXB68gM5RQxosVOOmpNlhah1IBkNJ7nNlPMt/gcKY6YsvKUBunrKn1R7bcxyRatnNAnh6bs7T0wVAwyvvLYZyqSA4IxV6QZiIE9f15KL+1Yg7Swhv1HiWlSd4nLLnvKgx0VweA5g8A7QIeVYl2Mk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612448061663473.35982221912525; Thu, 4 Feb 2021 06:14:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-KZ3upAA7N_Sz4sbgA3mRxw-1; Thu, 04 Feb 2021 09:14:18 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F571C7405; Thu, 4 Feb 2021 14:14:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF75E60C72; Thu, 4 Feb 2021 14:14:11 +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 91F485807D; Thu, 4 Feb 2021 14:14:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 114EDkLh031547 for ; Thu, 4 Feb 2021 09:13:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 313B15D9F4; Thu, 4 Feb 2021 14:13:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6CB25D9EF for ; Thu, 4 Feb 2021 14:13:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612448060; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NvFFY94GWKHlZU83kg4dnepogD24tgBCtnMR+Y/hTrA=; b=BSfzNux2BDB81UJ/3+YI6hWK11Bm1Mh6sv2H1/8hfBZkpzkrZKIm61khVnWqp1AVA8oX+9 uo+N6aU85njjj+me3pGqUXL/Jz7xWd8km3GgoCQwBMs97sP7RQZRo9h3tfm8dUnvE9vxtn m0HAtGdfl1zeiXy6hwc7kNqfnTNZXto= X-MC-Unique: KZ3upAA7N_Sz4sbgA3mRxw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 01/12] lib: Substitute some STREQLEN with STRPREFIX Date: Thu, 4 Feb 2021 15:13:26 +0100 Message-Id: <8094c50eb17f6cf0375a0a4d756eb1093484223f.1612447905.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.79 on 10.5.11.12 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) Content-Type: text/plain; charset="utf-8" There are few cases where STREQLEN() is called like this: STREQLEN(var, string, strlen(string)) which is the same as STRPREFIX(var, string). Use STRPREFIX() because it is more obvious what the check is doing. Signed-off-by: Michal Privoznik --- src/libxl/xen_xl.c | 2 +- src/util/vircgroupv2.c | 10 +++++----- tools/vsh.c | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 941832ce4e..69b139354e 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -950,7 +950,7 @@ xenParseXLUSBController(virConfPtr conf, virDomainDefPt= r def) else usbctrl_type =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2; } else { - if (STREQLEN(type, "qusb", 4)) { + if (STRPREFIX(type, "qusb")) { if (usbctrl_version =3D=3D 1) usbctrl_type =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_Q= USB1; else diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 4a239f067a..49acd27714 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -938,7 +938,7 @@ virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group, } tmp +=3D strlen(name); =20 - if (STREQLEN(tmp, "max", 3)) { + if (STRPREFIX(tmp, "max")) { *riops =3D 0; } else if (virStrToLong_ui(tmp, &tmp, 10, riops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1007,7 +1007,7 @@ virCgroupV2GetBlkioDeviceWriteIops(virCgroupPtr group, } tmp +=3D strlen(name); =20 - if (STREQLEN(tmp, "max", 3)) { + if (STRPREFIX(tmp, "max")) { *wiops =3D 0; } else if (virStrToLong_ui(tmp, &tmp, 10, wiops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1076,7 +1076,7 @@ virCgroupV2GetBlkioDeviceReadBps(virCgroupPtr group, } tmp +=3D strlen(name); =20 - if (STREQLEN(tmp, "max", 3)) { + if (STRPREFIX(tmp, "max")) { *rbps =3D 0; } else if (virStrToLong_ull(tmp, &tmp, 10, rbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1145,7 +1145,7 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group, } tmp +=3D strlen(name); =20 - if (STREQLEN(tmp, "max", 3)) { + if (STRPREFIX(tmp, "max")) { *wbps =3D 0; } else if (virStrToLong_ull(tmp, &tmp, 10, wbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1578,7 +1578,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group, return -1; } =20 - if (STREQLEN(str, "max", 3)) { + if (STRPREFIX(str, "max")) { *cfs_quota =3D VIR_CGROUP_CPU_QUOTA_MAX; return 0; } diff --git a/tools/vsh.c b/tools/vsh.c index 0e2d4955b4..a242619b8a 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2568,7 +2568,6 @@ static char ** vshReadlineCommandGenerator(const char *text) { size_t grp_list_index =3D 0, cmd_list_index =3D 0; - size_t len =3D strlen(text); const char *name; const vshCmdGrp *grp; const vshCmdDef *cmds; @@ -2588,7 +2587,7 @@ vshReadlineCommandGenerator(const char *text) if (cmds[cmd_list_index++].flags & VSH_CMD_FLAG_ALIAS) continue; =20 - if (STREQLEN(name, text, len)) { + if (STRPREFIX(name, text)) { if (VIR_REALLOC_N(ret, ret_size + 2) < 0) { g_strfreev(ret); return NULL; --=20 2.26.2