From nobody Sun Feb 8 18:32:02 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=1601475419; cv=none; d=zohomail.com; s=zohoarc; b=BpmAVVLynEhF59vrANb1pM4dUP9m912P0vuTLeovfsz+g08zUuv7N8YJgJDu993ZEw3C8061ieYgUtsJbbGV9nFfcQBO1pG+AE/tM0zq0ZMnPoEYLi8NIqRcmkhs+3WKv4bCXsJX0NS6nfhhsRhgJ25ePEAS1L81S/x5hQ/8KbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601475419; 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=U5W9T8IxFJrGyBMukxiBQX4O3inF5SbJ+22kGa40swY=; b=Y6oMsEF5o7EukFOhqLtL/FqzITyfal/yGqdz7hD/u/wXb7I75UBva2u2Hre9hjaEeF4m+lNulME2/DwIH46XdG5Hn1MNYKU0xZnYo8jI+vfP17vXqz6siqty5m9hn95DKVilsLqbSxbQ2345kP6ppebF+eM7T7KyPOlf18wRqos= 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 1601475419764563.0672261621355; Wed, 30 Sep 2020 07:16:59 -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-583-qq3_a8-jNkiDjyMC6wa61A-1; Wed, 30 Sep 2020 10:16:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B947C186DD2A; Wed, 30 Sep 2020 14:16:48 +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 9757E5DA76; Wed, 30 Sep 2020 14:16:48 +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 270CD183D025; Wed, 30 Sep 2020 14:16:48 +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 08UEB21K017619 for ; Wed, 30 Sep 2020 10:11:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id D35C16198B; Wed, 30 Sep 2020 14:11:02 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BEA860C07 for ; Wed, 30 Sep 2020 14:11:02 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601475418; 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=U5W9T8IxFJrGyBMukxiBQX4O3inF5SbJ+22kGa40swY=; b=d2oB/J8vBySF8Y78J7uhsmRgaqy5pLAl4IUh7LhluFvUCI87E2pBWrpoUYTJm9P1U6LdV6 xpvamZ6cQJstY5Q0lOxeum6iBbKEpzwtxep6r1dZAfBiqwJetrJvjPxA/BpyDZlkSubGsY hE3bCUsAkWuWUu6ZN1epoyPCdjednk8= X-MC-Unique: qq3_a8-jNkiDjyMC6wa61A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] gendispatch: use g_new0 instead of VIR_ALLOC Date: Wed, 30 Sep 2020 16:10:54 +0200 Message-Id: <557e77c0a9f1346aef9f6988f8e9261fa65362f7.1601475025.git.jtomko@redhat.com> 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.14 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) Take the easy way out and use typeof, because my life is too short to spend it reading gendispatch.pl. Signed-off-by: J=C3=A1n Tomko --- src/rpc/gendispatch.pl | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 0b2ae59910..91575f4d34 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -797,8 +797,7 @@ elsif ($mode eq "server") { push(@free_list, " VIR_FREE($1);"); push(@free_list_on_error, "VIR_FREE($1_p);"); push(@prepare_ret_list, - "if (VIR_ALLOC($1_p) < 0)\n" . - " goto cleanup;\n" . + "$1_p =3D g_new0(char *, 1);\n" . "\n" . " *$1_p =3D g_strdup($1);\n"); =20 @@ -1126,9 +1125,9 @@ elsif ($mode eq "server") { =20 if ($single_ret_as_list) { print " /* Allocate return buffer. */\n"; - print " if (VIR_ALLOC_N(ret->$single_ret_list_name.${si= ngle_ret_list_name}_val," . - " args->$single_ret_list_max_var) < 0)\n"; - print " goto cleanup;\n"; + print " ret->$single_ret_list_name.${single_ret_list_na= me}_val =3D\n"; + print " g_new0(typeof(*ret->$single_ret_list_name.$= {single_ret_list_name}_val), " . + "args->$single_ret_list_max_var); \n"; print "\n"; } =20 @@ -1188,8 +1187,8 @@ elsif ($mode eq "server") { print " }\n"; print "\n"; print " if (result && nresults) {\n"; - print " if (VIR_ALLOC_N(ret->$single_ret_list_name.${si= ngle_ret_list_name}_val, nresults) < 0)\n"; - print " goto cleanup;\n"; + print " ret->$single_ret_list_name.${single_ret_list_na= me}_val =3D\n"; + print " g_new0(typeof(*ret->$single_ret_list_name.$= {single_ret_list_name}_val), nresults);\n"; print "\n"; print " ret->$single_ret_list_name.${single_ret_list_na= me}_len =3D nresults;\n"; if ($modern_ret_is_nested) { @@ -1950,8 +1949,7 @@ elsif ($mode eq "client") { $priv_src =3D~ s/->conn//; } print " if (result) {\n"; - print " if (VIR_ALLOC_N(tmp_results, ret.$single_ret_li= st_name.${single_ret_list_name}_len + 1) < 0)\n"; - print " goto cleanup;\n"; + print " tmp_results =3D g_new0(typeof(*tmp_results), re= t.$single_ret_list_name.${single_ret_list_name}_len + 1);\n"; print "\n"; print " for (i =3D 0; i < ret.$single_ret_list_name.${s= ingle_ret_list_name}_len; i++) {\n"; print " tmp_results[i] =3D get_nonnull_$modern_ret_= struct_name($priv_src, ret.$single_ret_list_name.${single_ret_list_name}_va= l[i]);\n"; --=20 2.26.2