From nobody Mon Feb 9 16:53:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580481245545284.95043319160527; Fri, 31 Jan 2020 06:34:05 -0800 (PST) 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-401-nvigG4UhOM6BKN_Z0nGyMg-1; Fri, 31 Jan 2020 09:33:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33F7D8010EA; Fri, 31 Jan 2020 14:33:51 +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 0D74289E85; Fri, 31 Jan 2020 14:33:51 +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 BD62E180612F; Fri, 31 Jan 2020 14:33:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVnWZ019815 for ; Fri, 31 Jan 2020 09:31:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5E82B87B12; Fri, 31 Jan 2020 14:31:49 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8788986C4B; Fri, 31 Jan 2020 14:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481244; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=+j8z+r3ZK2n0PTWuPR+alyi8DL63qkjf9o/ihqOTMS8=; b=ai0VXwLmNWnCY8LkBMYxxUjDLYnIWRbW0ezyfromL16Nu1kATP8si/HnxCGo22v5fTbQGr 8+O1j30tEkOPFJJm0xqdjQe6cqM6A29rEE8qdNp3ZXzXyB+sT8/o9LDxoC72YNSg+3WcuZ WrXLDsHyteIHQ1ksbxpYQHl1+CgYJ6Y= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/19] virHashAddOrUpdateEntry: Simplify allocation of new entry Date: Fri, 31 Jan 2020 15:31:16 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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.13 X-MC-Unique: nvigG4UhOM6BKN_Z0nGyMg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use g_new0 and skip checking of the return value of keyCopy callback as both are bound to return a valid pointer. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virhash.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/util/virhash.c b/src/util/virhash.c index c57d9f8292..36a2d312fc 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -344,7 +344,6 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const vo= id *name, size_t key, len =3D 0; virHashEntryPtr entry; virHashEntryPtr last =3D NULL; - void *new_name; if ((table =3D=3D NULL) || (name =3D=3D NULL)) return -1; @@ -374,12 +373,8 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const v= oid *name, len++; } - if (VIR_ALLOC(entry) < 0 || !(new_name =3D table->keyCopy(name))) { - VIR_FREE(entry); - return -1; - } - - entry->name =3D new_name; + entry =3D g_new0(virHashEntry, 1); + entry->name =3D table->keyCopy(name); entry->payload =3D userdata; if (last) --=20 2.24.1