From nobody Sun Feb 8 12:52:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098582; cv=none; d=zohomail.com; s=zohoarc; b=DSaS8Ar5mF0E1RxYL6+WucTCI3mX3Tqu3wqesT2mikoyUfAjFieSBzvoBSEiFT3kBcM1jJDTLzwgdbecPLx18meDoPRohzBFYuVo1fYkxcgFUL3QtO12P18tYRKJPrVsHsKhpt96UqnttHobfQcbdcRinmDAonJeY7ReaGdg77g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098582; 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=36zjFcXE8eks8U7Wf026CYlL8948klPizUbPPRYsSCY=; b=cYLecccYCeobLslIV7gwzd/2X1pRzh3f3NoLj/tX4z+WX9MNb6EGCpAosM47H5MzByQCUj2+yvAdcFQAkbsXAUjH69yOxwR4pTJeHs7iWuLD3rgPbHVG0yW6Bf7ORBw7IdrbYH1BAfGPIvycMFyDX00kdRiwPnoUMahkr7rwozk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098582410273.46766370008515; Wed, 7 Oct 2020 12:23:02 -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-212-14X3lapwNcWr5DNiSpIGkg-1; Wed, 07 Oct 2020 15:22:58 -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 CD416425DB; Wed, 7 Oct 2020 19:22:52 +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 A61B51001281; Wed, 7 Oct 2020 19:22:52 +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 7084F1832FD8; Wed, 7 Oct 2020 19:22:52 +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 097JMfZg005965 for ; Wed, 7 Oct 2020 15:22:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8AA7A100164C; Wed, 7 Oct 2020 19:22:41 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 130EB1001281 for ; Wed, 7 Oct 2020 19:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098581; 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=36zjFcXE8eks8U7Wf026CYlL8948klPizUbPPRYsSCY=; b=Rh6aqzYyYX/esY676hTDDO05It7kxtizFl7jEm/8HQaWD1amLLtyxWD30kRByzXoZbNQ4N uZVnf1ZJBe5Z4/D7D7J+MIkxjaG8c5OTicJoGq34HIkaI+HEYyj47FImjO3TUWNoGHZ1EJ 1mlZe/a/S28Hb4Di4Jei/tgU6Zu46Ak= X-MC-Unique: 14X3lapwNcWr5DNiSpIGkg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/13] conf: virsecretobj: use g_new0 Date: Wed, 7 Oct 2020 21:22:25 +0200 Message-Id: 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 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 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/conf/virsecretobj.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 81c9f2c346..c98d52f1e4 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -465,10 +465,7 @@ virSecretObjListGetUUIDsCallback(void *payload, if (data->uuids) { char *uuidstr; =20 - if (VIR_ALLOC_N(uuidstr, VIR_UUID_STRING_BUFLEN) < 0) { - data->error =3D true; - goto cleanup; - } + uuidstr =3D g_new0(char, VIR_UUID_STRING_BUFLEN); =20 virUUIDFormat(def->uuid, uuidstr); data->uuids[data->nuuids++] =3D uuidstr; @@ -590,11 +587,8 @@ virSecretObjListExport(virConnectPtr conn, .nsecrets =3D 0, .error =3D false }; =20 virObjectRWLockRead(secretobjs); - if (secrets && - VIR_ALLOC_N(data.secrets, virHashSize(secretobjs->objs) + 1) < 0) { - virObjectRWUnlock(secretobjs); - return -1; - } + if (secrets) + data.secrets =3D g_new0(virSecretPtr, virHashSize(secretobjs->objs= )); =20 virHashForEach(secretobjs->objs, virSecretObjListExportCallback, &data= ); virObjectRWUnlock(secretobjs); @@ -735,8 +729,7 @@ virSecretObjGetValue(virSecretObjPtr obj) return NULL; } =20 - if (VIR_ALLOC_N(ret, obj->value_size) < 0) - return NULL; + ret =3D g_new0(unsigned char, obj->value_size); memcpy(ret, obj->value, obj->value_size); =20 return ret; @@ -753,8 +746,7 @@ virSecretObjSetValue(virSecretObjPtr obj, g_autofree unsigned char *new_value =3D NULL; size_t old_value_size; =20 - if (VIR_ALLOC_N(new_value, value_size) < 0) - return -1; + new_value =3D g_new0(unsigned char, value_size); =20 old_value =3D obj->value; old_value_size =3D obj->value_size; @@ -846,8 +838,7 @@ virSecretLoadValue(virSecretObjPtr obj) goto cleanup; } =20 - if (VIR_ALLOC_N(contents, st.st_size + 1) < 0) - goto cleanup; + contents =3D g_new0(char, st.st_size + 1); =20 if (saferead(fd, contents, st.st_size) !=3D st.st_size) { virReportSystemError(errno, _("cannot read '%s'"), --=20 2.26.2