From nobody Wed May 8 20:03:52 2024 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=1601850256; cv=none; d=zohomail.com; s=zohoarc; b=EI/sdqLkps7RLp6njsiJMn/uRK6rNuZ+W2m4Jlm6cxJJapyt+Kyfu7ya839rByeWhwMmnudisrOdjFwuRgYbZLHrbUhBJpLHLN/fnmWyWrbFcS5PikgScE3mauBgbF9skoZ7Fs/tG5bVOQrhN47fV8Gf19e+7NQDA7zDGpjBs0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850256; 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=mbqzDEWIloitBYizPM+o6TuI6GykNqswLHnTjtE5O0M=; b=HsSZOnKY6l8NniHbNdwjd9mTFLh5P27Ndqcc7e5FvF1PVuAmH+yzwBMe9k+UNsJ7jL0d6xYh9suNy02QPk7ZmT6K/wJTroK43UqqwQbZB2s3zQjGgvCLwtwMk+wtJwmebnCjgR8h2u+CcejU4kKx+W4ShPfRGJ0SOD+6Vh/iVfQ= 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 1601850256928425.0858990820002; Sun, 4 Oct 2020 15:24:16 -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-310-Bo2IuUQqO8iX3w2Z1BZUxA-1; Sun, 04 Oct 2020 18:24:13 -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 A33A81DDF9; Sun, 4 Oct 2020 22:24:08 +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 815905D9CC; Sun, 4 Oct 2020 22:24:08 +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 47443181A88C; Sun, 4 Oct 2020 22:24:08 +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 094MO4MW031892 for ; Sun, 4 Oct 2020 18:24:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id E85455C22E; Sun, 4 Oct 2020 22:24:04 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 703F15C22B for ; Sun, 4 Oct 2020 22:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850255; 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=mbqzDEWIloitBYizPM+o6TuI6GykNqswLHnTjtE5O0M=; b=Fkl/3al6fDMzht3nvUHWOCU9tPLB5/uGyps5E051yY2FGJSQMObo4tJ9oGDuC5kogTxhiB ld1RN2/lt9plf9XT72+C2CbCsTJjsVRkcBq0EyVyr+oRS3Gc2hGtWs7/kfrju3r6Aus65i WEn2PeuPlWzQUc2SMKVqnx1FPAIv7Ss= X-MC-Unique: Bo2IuUQqO8iX3w2Z1BZUxA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] vz: separate if conditions in vzEatCookie Date: Mon, 5 Oct 2020 00:23:56 +0200 Message-Id: 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.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) Create a separate scope where 'tmp' variable can be used. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/vz/vz_driver.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 40b1828eb2..5b40f9a835 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2806,26 +2806,28 @@ vzEatCookie(const char *cookiein, int cookieinlen, = unsigned int flags) _("(_migration_cookie)"), &ctx))) goto error; =20 - if ((flags & VZ_MIGRATION_COOKIE_SESSION_UUID) - && (!(tmp =3D virXPathString("string(./session-uuid[1])", ctx)) + if (flags & VZ_MIGRATION_COOKIE_SESSION_UUID) { + if ((!(tmp =3D virXPathString("string(./session-uuid[1])", ctx)) || (VIR_ALLOC_N(mig->session_uuid, VIR_UUID_BUFLEN) < 0) || (virUUIDParse(tmp, mig->session_uuid) < 0))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing or malformed session-uuid element " - "in migration data")); - VIR_FREE(tmp); - goto error; + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing or malformed session-uuid element " + "in migration data")); + VIR_FREE(tmp); + goto error; + } } VIR_FREE(tmp); =20 - if ((flags & VZ_MIGRATION_COOKIE_DOMAIN_UUID) - && (!(tmp =3D virXPathString("string(./uuid[1])", ctx)) + if (flags & VZ_MIGRATION_COOKIE_DOMAIN_UUID) { + if ((!(tmp =3D virXPathString("string(./uuid[1])", ctx)) || (VIR_ALLOC_N(mig->uuid, VIR_UUID_BUFLEN) < 0) || (virUUIDParse(tmp, mig->uuid) < 0))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing or malformed uuid element in migration d= ata")); - VIR_FREE(tmp); - goto error; + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing or malformed uuid element in migrati= on data")); + VIR_FREE(tmp); + goto error; + } } VIR_FREE(tmp); =20 --=20 2.26.2 From nobody Wed May 8 20:03:52 2024 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=1601850260; cv=none; d=zohomail.com; s=zohoarc; b=LB/Fb0+Cl8248jgcAQHRorwoLXbAFpOBKOa4jiccqd5WypLiZHYDYLF4HKDlCgjem4i+Q95zwnSS9u4feb3QHBmVJvB+IeJfxSvYcY3xGeKr0hqjgMBgGfvvUMKzCoCWNzIRwVDzThvlx3tmEUFJqUJY4ptroOaj0qowX/e+NaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850260; 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=EsnQHkXixTDHiftbmaI4LL3ZCsUb9cDFGWpHtZJH66o=; b=R6hwcF/F6UkB/r3lDbDrbgo0xZ1JjndWngMsuh04MlwT3ZnqSJBFbopkilTR0GqejXib2cdRDzHqRhZoB05T7xwXAkTP8/f0XnoEUdHQFh2fRnCaJtnSJU7b741+qwzrXPV6Fb/UFUCP5pQkuc6vkLwgaje574dEX/UQlmzLE+s= 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 1601850260257643.3346010129717; Sun, 4 Oct 2020 15:24:20 -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-321-gujS7YuWPCeV8mNVcckrTQ-1; Sun, 04 Oct 2020 18:24:16 -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 C58591009639; Sun, 4 Oct 2020 22:24:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EFFC1002C08; Sun, 4 Oct 2020 22:24:10 +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 6DA3144A4C; Sun, 4 Oct 2020 22:24:10 +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 094MO8KL031922 for ; Sun, 4 Oct 2020 18:24:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id C45025C22B; Sun, 4 Oct 2020 22:24:08 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C07A5C22E for ; Sun, 4 Oct 2020 22:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850259; 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=EsnQHkXixTDHiftbmaI4LL3ZCsUb9cDFGWpHtZJH66o=; b=YkksEn1uF3Hi0ZtEAr00qOrmx01VLPM/pPZOH1Hj6zsVuGyU5YmvSqwBNEjyRtOVUsjRv/ /BskJVel4wwPQKLdMeibngaAvicSKMx8vfShQSWUHXLoe2iC4xWRNv5YE9mrQJWBQW6s/d 1vDOF+1hGFT2Ga6yRuwRkwjmuPqCdi8= X-MC-Unique: gujS7YuWPCeV8mNVcckrTQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] vz: vzEatCookie: use distinct 'tmp' variables Date: Mon, 5 Oct 2020 00:23:57 +0200 Message-Id: <185cfbc629555dd5f8ae73df59a0d1d6cf81ef59.1601850220.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.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) Mark both as g_autofree within their separate scopes. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/vz/vz_driver.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 5b40f9a835..dad7fe37b7 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2790,7 +2790,6 @@ vzEatCookie(const char *cookiein, int cookieinlen, un= signed int flags) { xmlDocPtr doc =3D NULL; xmlXPathContextPtr ctx =3D NULL; - char *tmp =3D NULL; vzMigrationCookiePtr mig =3D NULL; =20 if (VIR_ALLOC(mig) < 0) @@ -2807,29 +2806,29 @@ vzEatCookie(const char *cookiein, int cookieinlen, = unsigned int flags) goto error; =20 if (flags & VZ_MIGRATION_COOKIE_SESSION_UUID) { + g_autofree char *tmp =3D NULL; + if ((!(tmp =3D virXPathString("string(./session-uuid[1])", ctx)) || (VIR_ALLOC_N(mig->session_uuid, VIR_UUID_BUFLEN) < 0) || (virUUIDParse(tmp, mig->session_uuid) < 0))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing or malformed session-uuid element " "in migration data")); - VIR_FREE(tmp); goto error; } } - VIR_FREE(tmp); =20 if (flags & VZ_MIGRATION_COOKIE_DOMAIN_UUID) { + g_autofree char *tmp =3D NULL; + if ((!(tmp =3D virXPathString("string(./uuid[1])", ctx)) || (VIR_ALLOC_N(mig->uuid, VIR_UUID_BUFLEN) < 0) || (virUUIDParse(tmp, mig->uuid) < 0))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing or malformed uuid element in migrati= on data")); - VIR_FREE(tmp); goto error; } } - VIR_FREE(tmp); =20 if ((flags & VZ_MIGRATION_COOKIE_DOMAIN_NAME) && !(mig->name =3D virXPathString("string(./name[1])", ctx))) { --=20 2.26.2 From nobody Wed May 8 20:03:52 2024 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=1601850260; cv=none; d=zohomail.com; s=zohoarc; b=UgA36V6DcNrtyauFVJJoxpjUBHpJOVcgVWBEydSV1oqpK5iLX3aBxawvoX34cNookY9ZVcom4c4xImA59g0cBh7bQ80cvo0Qp4AYWDhBqh04vBjitwk+aX7ewM4M5p9M+soy0lXeYQbjyW6wn/YdrgZngTPJFZhEs6+/Xnuxee8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850260; 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=24SIEnzz0E/KpWO37TGSOcvLbnTHAH8C6EqsnZfTp18=; b=dvngWwN/g4zJLJ347I4Z9vJzDTh+miItc58oiuaAu38xGprXebuW1EkOAILODp0uN1hds8ve08qhop4UbVW6r0Aay7WMtxDRey2Sc+/vok12ZLQD64PI0QodQa84Snp1HJSjrjjzNizEkCBXlGvifSWwdJFLXMI/+v/kq6CyV5U= 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 1601850260791952.9748123989488; Sun, 4 Oct 2020 15:24:20 -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-48-34Kl1qWbMfKKg0PsMz7FNg-1; Sun, 04 Oct 2020 18:24:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 700EF802B48; Sun, 4 Oct 2020 22:24:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E2CD19697; Sun, 4 Oct 2020 22:24:11 +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 1B1FD44A5D; Sun, 4 Oct 2020 22:24:11 +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 094MO9Ud031929 for ; Sun, 4 Oct 2020 18:24:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 95B6A5C22E; Sun, 4 Oct 2020 22:24:09 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CFB25C22B for ; Sun, 4 Oct 2020 22:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850259; 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=24SIEnzz0E/KpWO37TGSOcvLbnTHAH8C6EqsnZfTp18=; b=OjLJdrZVjQJvJbRyo123ICvtToErS16RjyGcHrblOiCq/2GS522PVZmV/azktogQKfoJnz 9H+MH+Tg/P21b5wUm8ZbeqV/bBsI/UqFaxADayU4PsTbiX1iRNYnBu0FnOdKfYdKgRHJ0n nkVLsHhZWNWL4d4JjzqKpU9vQJlFx1c= X-MC-Unique: 34Kl1qWbMfKKg0PsMz7FNg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] vz: vzEatCookie: separate allocation Date: Mon, 5 Oct 2020 00:23:58 +0200 Message-Id: <66fa507cd32930e22a701fb9081eb77d2416a7c4.1601850220.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.12 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) Use g_new0 outside of the error condition. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/vz/vz_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index dad7fe37b7..a83d4117a4 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2807,9 +2807,9 @@ vzEatCookie(const char *cookiein, int cookieinlen, un= signed int flags) =20 if (flags & VZ_MIGRATION_COOKIE_SESSION_UUID) { g_autofree char *tmp =3D NULL; + mig->session_uuid =3D g_new0(unsigned char, VIR_UUID_BUFLEN); =20 if ((!(tmp =3D virXPathString("string(./session-uuid[1])", ctx)) - || (VIR_ALLOC_N(mig->session_uuid, VIR_UUID_BUFLEN) < 0) || (virUUIDParse(tmp, mig->session_uuid) < 0))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing or malformed session-uuid element " @@ -2820,9 +2820,9 @@ vzEatCookie(const char *cookiein, int cookieinlen, un= signed int flags) =20 if (flags & VZ_MIGRATION_COOKIE_DOMAIN_UUID) { g_autofree char *tmp =3D NULL; + mig->uuid =3D g_new0(unsigned char, VIR_UUID_BUFLEN); =20 if ((!(tmp =3D virXPathString("string(./uuid[1])", ctx)) - || (VIR_ALLOC_N(mig->uuid, VIR_UUID_BUFLEN) < 0) || (virUUIDParse(tmp, mig->uuid) < 0))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing or malformed uuid element in migrati= on data")); --=20 2.26.2 From nobody Wed May 8 20:03:52 2024 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=1601850268; cv=none; d=zohomail.com; s=zohoarc; b=lLIOdvj8XzUAIHVTERgvQDoHxfUDuOz2CSHScrm8B81pBQM9flPrnhMmfW9exz9Pg6h8kcFH1ZAXBjYFKhoHYhveJ9/zPoewLkSdTMtSccjbS7SmtdnyOzDlb9iGmt51qlp0cqpx3GdG4OchMnQ6hLADtVLhi+s0IVB6Jf1wfyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850268; 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=u7j4l8KJpRyp2DMDIOMPxk/+MfVQJwR2loDafdk8454=; b=VfZHoxDyug4hr7dggoJ31RwbMbxogRoS6tzY6R7VE1vtDHT5C2rxKnsUGuoe4qK5wJsdxNHCrWdpWrOh47NJt82aWfvMakb8a7A9iYlxoVKguSTzTB/xmx/COhlsLQ5FokD+PF4jsit1jeT97dl3VJXzJG6TjKFa8mFyaiU7xJU= 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 1601850268985237.12895686837294; Sun, 4 Oct 2020 15:24:28 -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-307-5QDaklbKNPG0tRC58a3VZA-1; Sun, 04 Oct 2020 18:24:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE1FD801ABE; Sun, 4 Oct 2020 22:24:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 846DE5C22B; Sun, 4 Oct 2020 22:24:11 +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 5422544A5F; Sun, 4 Oct 2020 22:24:11 +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 094MOANH031942 for ; Sun, 4 Oct 2020 18:24:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 66A545C22E; Sun, 4 Oct 2020 22:24:10 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id E34665C22B for ; Sun, 4 Oct 2020 22:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850265; 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=u7j4l8KJpRyp2DMDIOMPxk/+MfVQJwR2loDafdk8454=; b=QRC3l6ATKVx+gWNHumBQ5KdE76aLcdHP8K0Bse80bUtTKqPnQzHuKw2siCETVAjvr97pKQ N8BDkv0vSTu2ykPAj04QDP3mKj8AvaJAmAU+3BYZ+e2yu192kp8wodzNsPzBZO2kPyBkPl UPVGmFUnb8SQ4kZC1pjZvID07f49ZYU= X-MC-Unique: 5QDaklbKNPG0tRC58a3VZA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] vz: use g_new0 instead of VIR_ALLOC Date: Mon, 5 Oct 2020 00:23:59 +0200 Message-Id: <2c0cf0356e12abc73fac6d635d0c7f09a37cec15.1601850220.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.16 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 Reviewed-by: Erik Skultety --- src/vz/vz_driver.c | 12 ++++-------- src/vz/vz_sdk.c | 46 ++++++++++++++-------------------------------- src/vz/vz_utils.c | 3 +-- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index a83d4117a4..8d47b90bdb 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -380,8 +380,7 @@ vzConnectOpen(virConnectPtr conn, if (!(driver =3D vzGetDriverConnection())) return VIR_DRV_OPEN_ERROR; =20 - if (VIR_ALLOC(privconn) < 0) - goto error; + privconn =3D g_new0(vzConn, 1); =20 conn->privateData =3D privconn; privconn->driver =3D driver; @@ -2792,8 +2791,7 @@ vzEatCookie(const char *cookiein, int cookieinlen, un= signed int flags) xmlXPathContextPtr ctx =3D NULL; vzMigrationCookiePtr mig =3D NULL; =20 - if (VIR_ALLOC(mig) < 0) - return NULL; + mig =3D g_new0(vzMigrationCookie, 1); =20 if (!cookiein || cookieinlen <=3D 0 || cookiein[cookieinlen - 1] !=3D = '\0') { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3717,8 +3715,7 @@ vzDomainGetAllStats(virConnectPtr conn, virDomainStatsRecordPtr stat; int maxparams =3D 0; =20 - if (VIR_ALLOC(stat) < 0) - return NULL; + stat =3D g_new0(virDomainStatsRecord, 1); =20 if (vzDomainGetStateStats(dom, stat, &maxparams) < 0) goto error; @@ -3802,8 +3799,7 @@ vzConnectGetAllDomainStats(virConnectPtr conn, return -1; } =20 - if (VIR_ALLOC_N(tmpstats, ndoms + 1) < 0) - goto cleanup; + tmpstats =3D g_new0(virDomainStatsRecordPtr, ndoms + 1); =20 for (i =3D 0; i < ndoms; i++) { virDomainStatsRecordPtr tmp; diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 3e7d55c50b..c6ed9bf9ce 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -70,16 +70,14 @@ logPrlErrorHelper(PRL_RESULT err, const char *filename, /* Get required buffer length */ PrlApi_GetResultDescription(err, PRL_TRUE, PRL_FALSE, NULL, &len); =20 - if (VIR_ALLOC_N(msg1, len) < 0) - goto cleanup; + msg1 =3D g_new0(char, len); =20 /* get short error description */ PrlApi_GetResultDescription(err, PRL_TRUE, PRL_FALSE, msg1, &len); =20 PrlApi_GetResultDescription(err, PRL_FALSE, PRL_FALSE, NULL, &len); =20 - if (VIR_ALLOC_N(msg2, len) < 0) - goto cleanup; + msg2 =3D g_new0(char, len); =20 /* get long error description */ PrlApi_GetResultDescription(err, PRL_FALSE, PRL_FALSE, msg2, &len); @@ -88,7 +86,6 @@ logPrlErrorHelper(PRL_RESULT err, const char *filename, filename, funcname, linenr, _("%s %s"), msg1, msg2); =20 - cleanup: VIR_FREE(msg1); VIR_FREE(msg2); } @@ -122,22 +119,19 @@ logPrlEventErrorHelper(PRL_HANDLE event, const char *= filename, =20 PrlEvent_GetErrString(event, PRL_TRUE, PRL_FALSE, NULL, &len); =20 - if (VIR_ALLOC_N(msg1, len) < 0) - goto cleanup; + msg1 =3D g_new0(char, len); =20 PrlEvent_GetErrString(event, PRL_TRUE, PRL_FALSE, msg1, &len); =20 PrlEvent_GetErrString(event, PRL_FALSE, PRL_FALSE, NULL, &len); =20 - if (VIR_ALLOC_N(msg2, len) < 0) - goto cleanup; + msg2 =3D g_new0(char, len); =20 PrlEvent_GetErrString(event, PRL_FALSE, PRL_FALSE, msg2, &len); =20 virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INTERNAL_ERROR, filename, funcname, linenr, _("%s %s"), msg1, msg2); - cleanup: VIR_FREE(msg1); VIR_FREE(msg2); } @@ -306,8 +300,7 @@ prlsdkGetStringParamVar(prlsdkParamGetterType getter, P= RL_HANDLE handle) pret =3D getter(handle, NULL, &buflen); prlsdkCheckRetGoto(pret, error); =20 - if (VIR_ALLOC_N(str, buflen) < 0) - goto error; + str =3D g_new0(char, buflen); =20 pret =3D getter(handle, str, &buflen); prlsdkCheckRetGoto(pret, error); @@ -582,11 +575,8 @@ prlsdkAddDomainVideoInfoVm(PRL_HANDLE sdkdom, virDomai= nDefPtr def) ret =3D PrlVmCfg_GetVideoRamSize(sdkdom, &videoRam); prlsdkCheckRetGoto(ret, error); =20 - if (VIR_ALLOC(video) < 0) - goto error; - - if (VIR_ALLOC(accel) < 0) - goto error; + video =3D g_new0(virDomainVideoDef, 1); + accel =3D g_new0(virDomainVideoAccelDef, 1); =20 if (VIR_APPEND_ELEMENT_COPY(def->videos, def->nvideos, video) < 0) goto error; @@ -773,8 +763,7 @@ prlsdkGetFSInfo(PRL_HANDLE prldisk, goto cleanup; } fs->type =3D VIR_DOMAIN_FS_TYPE_VOLUME; - if (VIR_ALLOC(fs->src->srcpool) < 0) - goto cleanup; + fs->src->srcpool =3D g_new0(virStorageSourcePoolDef, 1); fs->src->srcpool->pool =3D g_strdup(matches[1]); fs->src->srcpool->volume =3D g_strdup(matches[2]); VIR_FREE(buf); @@ -914,8 +903,7 @@ prlsdkParseNetAddress(char *addr) *maskstr =3D '\0'; ++maskstr; =20 - if (VIR_ALLOC(ip) < 0) - goto cleanup; + ip =3D g_new0(virNetDevIPAddr, 1); =20 if (virSocketAddrParse(&ip->address, addr, AF_UNSPEC) < 0) goto cleanup; @@ -962,8 +950,7 @@ prlsdkGetNetAddresses(PRL_HANDLE sdknet, virDomainNetDe= fPtr net) pret =3D PrlStrList_GetItem(addrlist, i, NULL, &buflen); prlsdkCheckRetGoto(pret, cleanup); =20 - if (VIR_ALLOC_N(addr, buflen) < 0) - goto cleanup; + addr =3D g_new0(char, buflen); =20 pret =3D PrlStrList_GetItem(addrlist, i, addr, &buflen); prlsdkCheckRetGoto(pret, cleanup); @@ -1145,8 +1132,7 @@ prlsdkAddDomainNetInfo(PRL_HANDLE sdkdom, virDomainDe= fPtr def) ret =3D PrlVmCfg_GetNetAdapter(sdkdom, i, &netAdapter); prlsdkCheckRetGoto(ret, error); =20 - if (VIR_ALLOC(net) < 0) - goto error; + net =3D g_new0(virDomainNetDef, 1); =20 if (prlsdkGetNetInfo(netAdapter, net, IS_CT(def)) < 0) goto error; @@ -1333,8 +1319,7 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr d= ef) if (vncMode =3D=3D PRD_DISABLED) return 0; =20 - if (VIR_ALLOC(gr) < 0) - goto error; + gr =3D g_new0(virDomainGraphicsDef, 1); =20 if (!(passwd =3D prlsdkGetStringParamVar(PrlVmCfg_GetVNCPassword, sdkd= om))) goto error; @@ -1351,9 +1336,7 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr d= ef) gr->type =3D VIR_DOMAIN_GRAPHICS_TYPE_VNC; gr->data.vnc.port =3D port; =20 - if (VIR_ALLOC(gr->listens) < 0) - goto error; - + gr->listens =3D g_new0(virDomainGraphicsListenDef, 1); gr->nListens =3D 1; =20 if (!(gr->listens[0].address =3D prlsdkGetStringParamVar(PrlVmCfg_GetV= NCHostName, @@ -4652,8 +4635,7 @@ prlsdkParseSnapshotTree(const char *treexml) if (nodes[i]->parent =3D=3D root) continue; =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; + def =3D g_new0(virDomainSnapshotDef, 1); =20 ctxt->node =3D nodes[i]; =20 diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index c31ff53cfb..4a79b55f3e 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -556,8 +556,7 @@ vzDomObjAlloc(void *opaque G_GNUC_UNUSED) { vzDomObjPtr pdom =3D NULL; =20 - if (VIR_ALLOC(pdom) < 0) - return NULL; + pdom =3D g_new0(struct vzDomObj, 1); =20 if (virCondInit(&pdom->job.cond) < 0) goto error; --=20 2.26.2