From nobody Sun Feb 8 05:30:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1601920141; cv=none; d=zohomail.com; s=zohoarc; b=TLgE3Rhx4jKrt7mIe/RSVwaOwFTV7ZwgKsWeJOABqmE3jDF9LbHEKNRfaSoQ3YuclZLb1YzFwCi5hVLjrGVdkWmEO1RE2KqAXeKgyFvebvHHIb8XHD6FyKsQLYGAkhOM9yOhSR6uiOVixMmaUPC7WiahjUlLss6FzqaWUYZXyQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920141; 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=6yxbEVmKLM4wYcgzaOPY0/3A5jkxwDhsyo+qzT4hlyM=; b=nPgWZUFPqRrhhdpenD0/F1IGoB2arxBp/RSTkx9UC5eIJhLWsUluowQmQJLN+k8A60IDwNW84yCPqmDskPZFXdonDa1+hyeuUMV9ghID7YD9kXKvKsSk3afOrJUsFaymC5eCIKZeehW3hikCuNm60S3dJAJ/CbTAFyzjTZMu0CA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601920141357292.89871800365484; Mon, 5 Oct 2020 10:49:01 -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-339-i9jKevo8N_OU931NF2gfVw-1; Mon, 05 Oct 2020 13:48:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 718B6AE830; Mon, 5 Oct 2020 17:48:50 +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 5162078819; Mon, 5 Oct 2020 17:48:50 +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 03B701826D37; Mon, 5 Oct 2020 17:48:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095HmcM4015619 for ; Mon, 5 Oct 2020 13:48:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id A12DA5C1C4; Mon, 5 Oct 2020 17:48:38 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28C9B5C1BD for ; Mon, 5 Oct 2020 17:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920140; 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=6yxbEVmKLM4wYcgzaOPY0/3A5jkxwDhsyo+qzT4hlyM=; b=ZHdFUGp6VzpeMRVCdY7wv7izHGw1uQvtdYkcb9raXg/STLb7F1wwT9LRfBSueyd0WwjLac TGfIucTvh6I32hyuVJIxBgE4k6eoljlhWhXxTFNwbh247jpH1u/STMU+Tr4lAHKPZZ2MM9 My7ZqEe1OIoQtrvuYGogxMYdXuPzIHs= X-MC-Unique: i9jKevo8N_OU931NF2gfVw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 06/12] util: command: use g_new0 Date: Mon, 5 Oct 2020 19:48:21 +0200 Message-Id: <002d196be41994c477ca47716c3d94a5ebd4bd08.1601920046.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.11 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) Signed-off-by: J=C3=A1n Tomko --- src/util/vircommand.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 8060cdfada..6350e77523 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -935,8 +935,7 @@ virCommandNewArgs(const char *const*args) { virCommandPtr cmd; =20 - if (VIR_ALLOC(cmd) < 0) - return NULL; + cmd =3D g_new0(virCommand, 1); =20 cmd->handshakeWait[0] =3D -1; cmd->handshakeWait[1] =3D -1; @@ -2183,21 +2182,18 @@ virCommandProcessIO(virCommandPtr cmd) if (cmd->outbuf) { outfd =3D cmd->outfd; VIR_FREE(*cmd->outbuf); - if (VIR_ALLOC_N(*cmd->outbuf, 1) < 0) - ret =3D -1; + *cmd->outbuf =3D g_new0(char, 1); } if (cmd->errbuf) { errfd =3D cmd->errfd; VIR_FREE(*cmd->errbuf); - if (VIR_ALLOC_N(*cmd->errbuf, 1) < 0) - ret =3D -1; + *cmd->errbuf =3D g_new0(char, 1); } if (ret =3D=3D -1) goto cleanup; ret =3D -1; =20 - if (VIR_ALLOC_N(fds, 3 + virCommandGetNumSendBuffers(cmd)) < 0) - goto cleanup; + fds =3D g_new0(struct pollfd, 3 + virCommandGetNumSendBuffers(cmd)); =20 for (;;) { size_t i; @@ -2636,8 +2632,7 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) VIR_FORCE_CLOSE(cmd->infd); /* clear any error so we can catch if the helper thread reports on= e */ cmd->has_error =3D 0; - if (VIR_ALLOC(cmd->asyncioThread) < 0) - ret =3D -1; + cmd->asyncioThread =3D g_new0(virThread, 1); =20 if (virThreadCreateFull(cmd->asyncioThread, true, virCommandDoAsyncIOHelper, @@ -2854,10 +2849,7 @@ int virCommandHandshakeWait(virCommandPtr cmd) if (c !=3D '1') { g_autofree char *msg =3D NULL; ssize_t len; - if (VIR_ALLOC_N(msg, 1024) < 0) { - VIR_FORCE_CLOSE(cmd->handshakeWait[0]); - return -1; - } + msg =3D g_new0(char, 1024); /* Close the handshakeNotify fd before trying to read anything * further on the handshakeWait pipe; so that a child waiting * on our acknowledgment will die rather than deadlock. */ @@ -3193,8 +3185,7 @@ virCommandRunRegex(virCommandPtr cmd, int ret =3D -1; =20 /* Compile all regular expressions */ - if (VIR_ALLOC_N(reg, nregex) < 0) - return -1; + reg =3D g_new0(GRegex *, nregex); =20 for (i =3D 0; i < nregex; i++) { g_autoptr(GError) err =3D NULL; @@ -3212,8 +3203,7 @@ virCommandRunRegex(virCommandPtr cmd, } =20 /* Storage for matched variables */ - if (VIR_ALLOC_N(groups, totgroups) < 0) - goto cleanup; + groups =3D g_new0(char *, totgroups); =20 virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, exitstatus) < 0) @@ -3299,8 +3289,7 @@ virCommandRunNul(virCommandPtr cmd, if (n_columns =3D=3D 0) return -1; =20 - if (VIR_ALLOC_N(v, n_columns) < 0) - return -1; + v =3D g_new0(char *, n_columns); for (i =3D 0; i < n_columns; i++) v[i] =3D NULL; =20 --=20 2.26.2