From nobody Mon Feb 9 02:50:54 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=1639421046; cv=none; d=zohomail.com; s=zohoarc; b=NiuqKLoiPp94RRG9AYLcaCVoSAPLyGfPZGjfiEPfXZU9ryv0o3H9cjB1txleq6XDxkDjHbdkMOTcHFL1FCGjWQ+XDXf/lVQnq2BjMTN38tw+AjkMBgyf93hcVkv5nekM+qAKgs+dZVPAXlATGF3O8aZNwExs7T95USiLZJt7kS4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639421046; 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=4hbIprY51apggaQB8h2x4y231i2i5KC0GnWxlhhdyC4=; b=iW7rpnnTzJDitnIOCZDHmzSP1uQ1i1JxwK3auyymT6GX0SzVDIjldqI5qoGaRdSYTEG8+kTpzIP1oBJRD88dhF1Yjk2sn3S3JMJ3Cy8PRdFA2sLQWv2Nqc1TKvilhN6mgF5LX8CXtVb47eGwEL1JWzetenEQkkOAPYGIkhvV2sk= 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 1639421046358294.75395029424317; Mon, 13 Dec 2021 10:44:06 -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-298-0LE1WWwtNACp6kAZousGAg-1; Mon, 13 Dec 2021 13:44:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6443B10168FE; Mon, 13 Dec 2021 18:43:53 +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 225C15BE24; Mon, 13 Dec 2021 18:43:53 +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 DFCF01806D1C; Mon, 13 Dec 2021 18:43:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BDIhL4U003862 for ; Mon, 13 Dec 2021 13:43:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id AB88E60C04; Mon, 13 Dec 2021 18:43:21 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 332986107F for ; Mon, 13 Dec 2021 18:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639421045; 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=4hbIprY51apggaQB8h2x4y231i2i5KC0GnWxlhhdyC4=; b=K9bBvWf1yHOFhXP2X1qzgf9Il/GuwZGMsGVEbszpT2gsA/acWaxF/lj77mn8My+4Na+pki TMICkGH1zYhzQaCQDE1NHiV4v4j6k2tYg1vaYQp7y698xACRQF1o4uLhXUqFICFTyPyDkZ 8DyZVqQ5nHb04hom439+s6YbncF8Yj0= X-MC-Unique: 0LE1WWwtNACp6kAZousGAg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/20] openvz: refactor openvzConnectListDomains Date: Mon, 13 Dec 2021 19:43:00 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639421046832100004 Use g_auto where possible, reduce scope of some variables and remove pointless ret and rc variables. Signed-off-by: J=C3=A1n Tomko --- src/openvz/openvz_driver.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index cffdb20898..fa5ded54ec 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1334,44 +1334,37 @@ static int openvzConnectListDomains(virConnectPtr c= onn G_GNUC_UNUSED, int *ids, int nids) { int got =3D 0; - int veid; - int outfd =3D -1; - int rc =3D -1; - int ret; - char buf[32]; - char *endptr; - virCommand *cmd =3D virCommandNewArgList(VZLIST, "-ovpsid", "-H", NULL= ); + VIR_AUTOCLOSE outfd =3D -1; + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZLIST, "-ovpsid", = "-H", NULL); =20 virCommandSetOutputFD(cmd, &outfd); if (virCommandRunAsync(cmd, NULL) < 0) - goto cleanup; + return -1; =20 while (got < nids) { - ret =3D openvz_readline(outfd, buf, 32); - if (!ret) + char *endptr; + char buf[32]; + int veid; + + if (openvz_readline(outfd, buf, 32) =3D=3D 0) break; if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse VPS ID %s"), buf); continue; } - ids[got] =3D veid; - got ++; + ids[got++] =3D veid; } =20 if (virCommandWait(cmd, NULL) < 0) - goto cleanup; + return -1; =20 if (VIR_CLOSE(outfd) < 0) { virReportSystemError(errno, "%s", _("failed to close file")); - goto cleanup; + return -1; } =20 - rc =3D got; - cleanup: - VIR_FORCE_CLOSE(outfd); - virCommandFree(cmd); - return rc; + return got; } =20 static int openvzConnectNumOfDomains(virConnectPtr conn) --=20 2.31.1