From nobody Sun Feb 8 20:12:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1637845177; cv=none; d=zohomail.com; s=zohoarc; b=bx8Qnnf9GAJICt8zHkQWoQ7cfMLwgP82ae+eHCgbXyj6BlWxYSwL9z+5DWPRvU2CcsoILj1I3mbzPPeyFMsrzqMs2UgygMVUEJtPYFoWaACf+XZxUTrFuMmg/e3gplswRQT2ZoWI1bdo+I1lJoM7I/EJ/2HW6VzutB7tyIzcRGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637845177; 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=Phnm07G1TXJ4RtjN/wH5ENG9JtLDDxd2c++8OpVzdz0=; b=dNNFRMgNQ27ydV7yiyWYw7/KwHXW1zIV4Xg/h27G0dbDeqv7n2kcvxox5ULE5n4kgjQPmkGN2QU2PAGEZGoeguOmGzVRwSKYHT9Srfq2MpFFe3z6IX18cDAIJPGFSNajQ5l8MG3J92MpMWwv/vQ6mN0ReUWUjQQYGhuJr/YviU8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1637845177124997.137047755857; Thu, 25 Nov 2021 04:59:37 -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-155-T9MpvDwPM9SUUkE20PNZYA-1; Thu, 25 Nov 2021 07:59:35 -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 F2C6283DD20; Thu, 25 Nov 2021 12:59:29 +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 D572F3E38; Thu, 25 Nov 2021 12:59:29 +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 A942F1809C8A; Thu, 25 Nov 2021 12:59:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1APCxHrG031003 for ; Thu, 25 Nov 2021 07:59:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id D212C5F4F4; Thu, 25 Nov 2021 12:59:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3482E5F4EF for ; Thu, 25 Nov 2021 12:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637845176; 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=Phnm07G1TXJ4RtjN/wH5ENG9JtLDDxd2c++8OpVzdz0=; b=D7mgzvp14zhBIBC8Na15Cuhy7D6A3YCs05nATG3zHY4IH0q2kR7f5tIUafbixh44z0O+vt oQc19faEFyNYyqGWqvnXdyb3gsDYaA//lAW2GyvLwbAgOkScGenEkWQ0VZscOq5gI2Ra33 Ewf+XE+ArlBHn5ik0HdMN1HCVak/Ap4= X-MC-Unique: T9MpvDwPM9SUUkE20PNZYA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/6] virDomainDeviceLoadparmIsValid: Simplify value lenght check Date: Thu, 25 Nov 2021 13:59:09 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1637845179075100005 Content-Type: text/plain; charset="utf-8" Use the new STRLIM macro and unify it with the empty string check. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 11 +++-------- .../machine-loadparm-s390-len-invalid.err | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0203d17e9d..c542782750 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6300,15 +6300,10 @@ virDomainDeviceLoadparmIsValid(const char *loadparm) { size_t i; - if (virStringIsEmpty(loadparm)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("loadparm cannot be an empty string")); - return false; - } - - if (strlen(loadparm) > 8) { + if (virStringIsEmpty(loadparm) || !STRLIM(loadparm, 8)) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("loadparm '%s' exceeds 8 characters"), loadparm); + _("loadparm value '%s' must be between 1 and 8 char= acters"), + loadparm); return false; } diff --git a/tests/qemuxml2argvdata/machine-loadparm-s390-len-invalid.err b= /tests/qemuxml2argvdata/machine-loadparm-s390-len-invalid.err index 9afaa68ae2..9fd0425f20 100644 --- a/tests/qemuxml2argvdata/machine-loadparm-s390-len-invalid.err +++ b/tests/qemuxml2argvdata/machine-loadparm-s390-len-invalid.err @@ -1 +1 @@ -internal error: loadparm 'LOADPARM1' exceeds 8 characters +internal error: loadparm value 'LOADPARM1' must be between 1 and 8 charact= ers --=20 2.31.1