From nobody Sun Feb 8 18:32:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1571925439; cv=none; d=zoho.com; s=zohoarc; b=dUGbKxeBpBIvaQ9QB7Uhq8UzoGQahT7RPwATURuOjnh2h84LQ5lS8yOgdJf95FCARMIJ+UBw3vvTRsUTTwbIHu9sqm9Op1wNa8P/Km682PqEXflGzjFTHRY3TnIciE/WI3vGvn8/imOpqV7IOGNr5/vlzOZvyhjfpj8CIMsIwsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571925439; 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=vyDHHU5l5ZXwY6azBcZ7OCuSqLuAsgmmYAUcGvACP20=; b=WzsIge9rJZZyN4Asfw05JFZYLiNKsV73T0HEF/b9Dohyx259DO2B1rbnNNH2GacsJAEfMgKgO27IyFMBjBJchBhoPxIsuG0QNUapYhX7+i06Qyd6HPYGa8hwIomCVBfyaOpxMuO0XtfkZVnEN4TXNBVdNqgwXKpKeYpWEUiv7Ew= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571925439348613.4107359182598; Thu, 24 Oct 2019 06:57:19 -0700 (PDT) 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-62-uGAu-YYFO9SsDJ7AWoraIA-1; Thu, 24 Oct 2019 09:57:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7464107AD38; Thu, 24 Oct 2019 13:57:09 +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 9FA55100EBA2; Thu, 24 Oct 2019 13:57:09 +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 611574EE7E; Thu, 24 Oct 2019 13:57:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9ODuoWZ026335 for ; Thu, 24 Oct 2019 09:56:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2107910027A9; Thu, 24 Oct 2019 13:56:50 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EE201000232 for ; Thu, 24 Oct 2019 13:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571925438; 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=vyDHHU5l5ZXwY6azBcZ7OCuSqLuAsgmmYAUcGvACP20=; b=ilgAJfIZ8+JCggGgY+NQJtmerHP8KiW2ICFMhH6aIyyYLqD9GZbFPsAqXYwQOY/+F43Tf5 ovhxJ+FkrTRe2SFiXkXZOZBJ8wPUyr/gWj37YSnXQEYV3+OMSOLuHzxXXzklCVWLMNoAo7 6ZzognDDBBgRLoe2iotbD4o2J28TDxA= From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 24 Oct 2019 15:56:24 +0200 Message-Id: <807b4a22306400657bac09af186e3045b2cf4098.1571925291.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/19] util: buffer: Don't treat missing truncation in virBufferTrim as usage error 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.22 X-MC-Unique: uGAu-YYFO9SsDJ7AWoraIA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Usage errors in the virBuffer are hard to track anyways. Just trim noting if the user requests the trimming string to be used without providing it. The change in the test proves that it's a noop now. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virbuffer.c | 6 +----- tests/virbuftest.c | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index bcf9042573..9a74ca78bb 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -784,8 +784,6 @@ virBufferStrcat(virBufferPtr buf, ...) * if the current tail of the buffer matches @str; a non-negative @len * further limits how much of the tail is trimmed. If @str is NULL, then * @len must be non-negative. - * - * Sets error to -1 (usage) if str is NULL and len is less than zero. */ void virBufferTrim(virBufferPtr buf, const char *str, int len) @@ -794,10 +792,8 @@ virBufferTrim(virBufferPtr buf, const char *str, int l= en) if (!buf || buf->error) return; - if (!str && len < 0) { - virBufferSetError(buf, -1); + if (!str && len < 0) return; - } if (len > 0 && len > buf->use) return; diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 385f016174..8b8754adfa 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -163,6 +163,7 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) virBufferTrim(buf, "a", 2); virBufferAddLit(buf, ",b,,"); + virBufferTrim(buf, NULL, -1); virBufferTrim(buf, "b", -1); virBufferTrim(buf, "b,,", 1); virBufferTrim(buf, ",", -1); @@ -178,12 +179,6 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) goto cleanup; } - virBufferTrim(buf, NULL, -1); - if (virBufferError(buf) !=3D -1) { - VIR_TEST_DEBUG("Usage error not flagged"); - goto cleanup; - } - ret =3D 0; cleanup: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list