From nobody Tue Feb 10 07:41:08 2026 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=1681373826; cv=none; d=zohomail.com; s=zohoarc; b=V35ar3LYzH3Qxr/yF51yEitVXMb5QAKcs+zaOn8KQpTXPioiFP0ccPjpnG91TVD/mBTUrfN4dOh0Nx/V2s2NwkMN1/lPIFbrSnAumfD+Y+0Ar6vTBiAn4neFWa5q649m+9/1yN7+mqO2Nz+x+lJrMzyqqEOq2ZcJLn1zGd/tNBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373826; 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=1q9A+cOWj2hiRQK/ETUwK6bn2lrirk4SSpm9jvXVqs8=; b=jGPLW8teh+Bh/D54K8jgz8boxdhIZitObgf9k9a1xLyjN45s+j7BPslM2JYOkWyl0ZD/TxJKspoOpxJSD7yld4nAYJ3l3rdDq1gngUWCPTHljKOLS4iJGZ3LdBhvtKy2bCKXx0GL7z1cZIdk8Yeu17/4Cms1PLFSAZPgd/3zy8g= 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 1681373826140795.4591416312438; Thu, 13 Apr 2023 01:17:06 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-244-W-IFONGlN_Wf6KfJvexpFQ-1; Thu, 13 Apr 2023 04:16:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8612A1871DB6; Thu, 13 Apr 2023 08:16:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EC711121320; Thu, 13 Apr 2023 08:16:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CD02719472F4; Thu, 13 Apr 2023 08:16:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1877A1946597 for ; Thu, 13 Apr 2023 08:16:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EF7772166B29; Thu, 13 Apr 2023 08:16:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 711782166B26 for ; Thu, 13 Apr 2023 08:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681373825; 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=1q9A+cOWj2hiRQK/ETUwK6bn2lrirk4SSpm9jvXVqs8=; b=MfJacay7d1G86sMMug/hQPxBpmz/JfRBprTDZqsq1WrWWl9VJjYoXSTaGGp4SqAQpttakr d0lw21KzofsQ+ZGYBBgFBf08wPW+yRB7WeB9qkbGXoEngPANtrDs4Tz+yP7aDie79d/8xT Sx3eHKGWJf1pG7Tgh+Df6MV2fDEghyo= X-MC-Unique: W-IFONGlN_Wf6KfJvexpFQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 4/8] vshPrint: Add version using 'va_list' Date: Thu, 13 Apr 2023 10:15:52 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1681373828264100007 Content-Type: text/plain; charset="utf-8" Add a version for functions which may already need to take a printf format string. Signed-off-by: Peter Krempa --- tools/vsh.c | 32 ++++++++++++++++++++++---------- tools/vsh.h | 4 ++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 5b672b8edf..41f55a91fa 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1865,34 +1865,46 @@ vshDebug(vshControl *ctl, int level, const char *fo= rmat, ...) fflush(stdout); } + void -vshPrintExtra(vshControl *ctl, const char *format, ...) +vshPrintVa(vshControl *ctl G_GNUC_UNUSED, + const char *format, + va_list ap) { - va_list ap; g_autofree char *str =3D NULL; + str =3D g_strdup_vprintf(format, ap); + fputs(str, stdout); + fflush(stdout); +} + + +void +vshPrintExtra(vshControl *ctl, + const char *format, + ...) +{ + va_list ap; + if (ctl && ctl->quiet) return; va_start(ap, format); - str =3D g_strdup_vprintf(format, ap); + vshPrintVa(ctl, format, ap); va_end(ap); - fputs(str, stdout); - fflush(stdout); } void -vshPrint(vshControl *ctl G_GNUC_UNUSED, const char *format, ...) +vshPrint(vshControl *ctl, + const char *format, + ...) { va_list ap; - g_autofree char *str =3D NULL; va_start(ap, format); - str =3D g_strdup_vprintf(format, ap); + vshPrintVa(ctl, format, ap); va_end(ap); - fputs(str, stdout); - fflush(stdout); } diff --git a/tools/vsh.h b/tools/vsh.h index 51f09cd2b0..377c5947c1 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -302,6 +302,10 @@ const vshCmdOpt *vshCommandOptArgv(vshControl *ctl, co= nst vshCmd *cmd, bool vshCommandArgvParse(vshControl *ctl, int nargs, char **argv); int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *time= out); +void vshPrintVa(vshControl *ctl, + const char *format, + va_list ap) + G_GNUC_PRINTF(2, 0); void vshPrint(vshControl *ctl, const char *format, ...) G_GNUC_PRINTF(2, 3); void vshPrintExtra(vshControl *ctl, const char *format, ...) --=20 2.39.2