From nobody Sun Feb 8 18:09:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1571755573; cv=none; d=zoho.com; s=zohoarc; b=a+1cEri4+YaDknel3gph7oUWqNZpzaPxUtgE82WVSAd0KS8rge5rr1JYAp4q52Z8V1KDZcrj0fnu5gR2enxi/NwvsTGMf0mdNq9hCuW2jD1WLeDOoV+zGVVemW42IWIs0gjO239o9Ib1grbDfXQua9PteQQ5ND/eVH46AMV+eVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571755573; h=Content-Type:Content-Transfer-Encoding:Cc: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=pvde2f9D5EsQXNtk9/8GtURMEnxkNYo5SBBlv7gK5nM=; b=Td2Ufk0CbeDOt1EkZqwicwqXRA/ZBRxn1rzE9ItIYBWjB6d0rwBYQC2IhNw7ppfOonN8syB73yHV3rbHlN5i/rhVdP0ew7Adre8B0buCoY9kUm3CvIbmFhvAzBAe2tiAjNvAuQSgoo+GJFElCgrSntV+ZMadVJcYGYVW9IQXdYU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571755573372459.32355282915967; Tue, 22 Oct 2019 07:46:13 -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-100-qFdOsZJrNIWrMwxuknkTGw-1; Tue, 22 Oct 2019 10:46:10 -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 7521E801E5F; Tue, 22 Oct 2019 14:46:05 +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 D95146012D; Tue, 22 Oct 2019 14:46:04 +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 0D8E5180B761; Tue, 22 Oct 2019 14:46:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9MEjt70006476 for ; Tue, 22 Oct 2019 10:45:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id E64E152CD; Tue, 22 Oct 2019 14:45:55 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 490EC52CC; Tue, 22 Oct 2019 14:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571755572; 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=pvde2f9D5EsQXNtk9/8GtURMEnxkNYo5SBBlv7gK5nM=; b=FIH4UDfHHFy+xSpLjmpiev9JDzHb/ioqkUQtCyXUwIWn74Si19EA6l/sx2PyGpZO0aC7+U fdwdhYjeVGOUx6Z1QCZjk5E4R+/2z+PRo2w1qao5SrqGV/+LEhPUt8x+74TvMHGa/BbKBg JpIX2NzJEAFIstGaTBeySt3sXZDpuMQ= From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 16:45:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/4] remote: Use g_new0 to allocate 'remote_string' in event RPC handlers 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 X-MC-Unique: qFdOsZJrNIWrMwxuknkTGw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Few events emit optional strings. We need to allocate the container for it first. Note that remote_nonnull_string is used as the type as the internal part of the string is nonnull if the container is present. Signed-off-by: Peter Krempa --- src/remote/remote_daemon_dispatch.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 392a32fed8..9d1fe5a095 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -721,14 +721,12 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn, /* build return data */ memset(&data, 0, sizeof(data)); if (oldSrcPath) { - if (VIR_ALLOC(data.oldSrcPath) < 0) - goto error; + data.oldSrcPath =3D g_new0(remote_nonnull_string, 1); *(data.oldSrcPath) =3D g_strdup(oldSrcPath); } if (newSrcPath) { - if (VIR_ALLOC(data.newSrcPath) < 0) - goto error; + data.newSrcPath =3D g_new0(remote_nonnull_string, 1); *(data.newSrcPath) =3D g_strdup(newSrcPath); } @@ -750,11 +748,6 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn, } return 0; - - error: - xdr_free((xdrproc_t)xdr_remote_domain_event_disk_change_msg, - (char *) &data); - return -1; } @@ -1262,8 +1255,7 @@ remoteRelayDomainEventMetadataChange(virConnectPtr co= nn, data.type =3D type; if (nsuri) { - if (VIR_ALLOC(data.nsuri) < 0) - goto error; + data.nsuri =3D g_new0(remote_nonnull_string, 1); *(data.nsuri) =3D g_strdup(nsuri); } @@ -1276,11 +1268,6 @@ remoteRelayDomainEventMetadataChange(virConnectPtr c= onn, &data); return 0; - - error: - xdr_free((xdrproc_t)xdr_remote_domain_event_callback_metadata_change_m= sg, - (char *) &data); - return -1; } @@ -1308,8 +1295,7 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr co= nn, data.callbackID =3D callback->callbackID; data.dev =3D g_strdup(dev); if (path) { - if (VIR_ALLOC(data.path) < 0) - goto error; + data.path =3D g_new0(remote_nonnull_string, 1); *(data.path) =3D g_strdup(path); } data.threshold =3D threshold; @@ -1321,11 +1307,6 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr c= onn, (xdrproc_t)xdr_remote_domain_event_block= _threshold_msg, &data); return 0; - - error: - xdr_free((xdrproc_t)xdr_remote_domain_event_block_threshold_msg, - (char *) &data); - return -1; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list