From nobody Thu Sep 19 00:58:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1721311737291233.17013056706753; Thu, 18 Jul 2024 07:08:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 33EE8A11; Thu, 18 Jul 2024 10:08:56 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E6BF0A2D; Thu, 18 Jul 2024 10:08:20 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 41FED9F0; Thu, 18 Jul 2024 10:08:16 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id D00269F9 for ; Thu, 18 Jul 2024 10:08:15 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-597-mHV_EgERO4-z_1Afy0J-9g-1; Thu, 18 Jul 2024 10:08:14 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0B9161954B30 for ; Thu, 18 Jul 2024 14:08:12 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 473C21955E80 for ; Thu, 18 Jul 2024 14:08:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721311695; h=from:from: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; bh=Tr70wlWyZlvKjjrFhc/Zs7Pg71LXEGh143Zz3PpOVXM=; b=ieK/6uGAlikxtQADawRWS+fTf1FK87tGV4huREZp8+dNsUJNFgM4TtpYuuQgEbH2nNPvMk rI2Y1SxzpKn3XNuIw4P+iM4Bk8MGfzLOMtyTzSG26b/t6NChpACM5sJdbSvhhUrYwELk6q 10mmTLP4c3nLfKFglJOkTTzqwu2FBa8= X-MC-Unique: mHV_EgERO4-z_1Afy0J-9g-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/5] vircommand: Initialize dryRunStatus to portable EXIT_SUCCESS instead of 0 Date: Thu, 18 Jul 2024 16:08:03 +0200 Message-ID: <734f4fad0545bde5bc34fc676e6561d429cc7418.1721311651.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 67BWUVF7EGPZ66VFFGEDKV5BEG63OZOK X-Message-ID-Hash: 67BWUVF7EGPZ66VFFGEDKV5BEG63OZOK X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1721311737938116600 Content-Type: text/plain; charset="utf-8"; x-default="true" If dry run of a command was requested (virCommandSetDryRun()) then a specified callback is called instead of running actual command. This is meant to be used in tests. To mimic running the command as closely as possible the callback can also set exit status of the command it's implementing. To save some lines though, the exit status is initialized to 0 so that callback has to set it only on failures. Now, 0 is not exactly portable value - that's why stdlib.h has EXIT_SUCCESS (and EXIT_FAILURE) values. Initialize the exit status (held in dryRunStatus) to EXIT_SUCCESS then. Signed-off-by: Michal Privoznik --- src/util/vircommand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 07bee9b12e..a03fcc37ae 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2630,7 +2630,7 @@ virCommandRunAsync(virCommand *cmd, pid_t *pid) =20 if (dryRunBuffer || dryRunCallback) { g_autofree char *cmdstr =3D NULL; - dryRunStatus =3D 0; + dryRunStatus =3D EXIT_SUCCESS; =20 if (!(cmdstr =3D virCommandToStringFull(cmd, dryRunBufferArgLinebr= eaks, dryRunBufferCommandStripPath= ))) --=20 2.44.2