From nobody Wed May 14 21:32:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516713932286182.71263750683158; Tue, 23 Jan 2018 05:25:32 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBE564D2DA; Tue, 23 Jan 2018 13:25:30 +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 93DC05EDEB; Tue, 23 Jan 2018 13:25:30 +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 580F04EE50; Tue, 23 Jan 2018 13:25:30 +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 w0NDOasg027045 for ; Tue, 23 Jan 2018 08:24:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 766947B14E; Tue, 23 Jan 2018 13:24:36 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0899617145; Tue, 23 Jan 2018 13:24:34 +0000 (UTC) From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Tue, 23 Jan 2018 13:23:42 +0000 Message-Id: <20180123132347.21944-7-berrange@redhat.com> In-Reply-To: <20180123132347.21944-1-berrange@redhat.com> References: <20180123132347.21944-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 06/11] rpc: pass virNetServer to post-exec restart callback in typesafe manner 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 23 Jan 2018 13:25:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The virNetServer class is passing a pointer to itself to the virNetServerClient as a 'void *' pointer. This is presumably due to fact that the virnetserverclient.h file doesn't see the virNetServerPtr typedef. The typedef is easily movable though, which lets us get typesafe parameter passing, removing the confusion of passing two distinct 'void *' pointers to one method. Signed-off-by: Daniel P. Berrange --- src/rpc/virnetserver.c | 6 +++--- src/rpc/virnetserverclient.c | 14 +++++++------- src/rpc/virnetserverclient.h | 9 ++++++--- src/rpc/virnetserverprogram.h | 3 --- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 77a4c0b8dc..5e50b58be8 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -540,12 +540,12 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSO= NValuePtr object, goto error; } =20 - if (!(client =3D virNetServerClientNewPostExecRestart(child, + if (!(client =3D virNetServerClientNewPostExecRestart(srv, + child, clientPrivNewP= ostExecRestart, clientPrivPreE= xecRestart, clientPrivFree, - clientPrivOpaq= ue, - srv))) + clientPrivOpaq= ue))) goto error; =20 if (virNetServerAddClient(srv, client) < 0) { diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 1f335d3b1e..d81a3892ff 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -479,12 +479,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned = long long id, } =20 =20 -virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr= object, +virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr= srv, + virJSONValuePtr= object, virNetServerCli= entPrivNewPostExecRestart privNew, virNetServerCli= entPrivPreExecRestart privPreExecRestart, virFreeCallback= privFree, - void *privOpaqu= e, - void *opaque) + void *privOpaqu= e) { virJSONValuePtr child; virNetServerClientPtr client =3D NULL; @@ -540,12 +540,12 @@ virNetServerClientPtr virNetServerClientNewPostExecRe= start(virJSONValuePtr objec =20 if (!virJSONValueObjectHasKey(object, "id")) { /* no ID found in, a new one must be generated */ - id =3D virNetServerNextClientID((virNetServerPtr) opaque); + id =3D virNetServerNextClientID(srv); } else { if (virJSONValueObjectGetNumberUlong(object, "id", &id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Malformed id field in JSON state document")); - return NULL; + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Malformed id field in JSON state document")); + return NULL; } } =20 diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h index 14ace9e522..3c48759abc 100644 --- a/src/rpc/virnetserverclient.h +++ b/src/rpc/virnetserverclient.h @@ -30,6 +30,9 @@ # include "virobject.h" # include "virjson.h" =20 +typedef struct _virNetServer virNetServer; +typedef virNetServer *virNetServerPtr; + typedef struct _virNetServerClient virNetServerClient; typedef virNetServerClient *virNetServerClientPtr; =20 @@ -71,12 +74,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned lo= ng long id, virFreeCallback privFree, void *privOpaque); =20 -virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr= object, +virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr= srv, + virJSONValuePtr= object, virNetServerCli= entPrivNewPostExecRestart privNew, virNetServerCli= entPrivPreExecRestart privPreExecRestart, virFreeCallback= privFree, - void *privOpaqu= e, - void *opaque); + void *privOpaqu= e); =20 virJSONValuePtr virNetServerClientPreExecRestart(virNetServerClientPtr cli= ent); =20 diff --git a/src/rpc/virnetserverprogram.h b/src/rpc/virnetserverprogram.h index 1731c9e1d1..c2a5635c95 100644 --- a/src/rpc/virnetserverprogram.h +++ b/src/rpc/virnetserverprogram.h @@ -31,9 +31,6 @@ typedef struct _virNetDaemon virNetDaemon; typedef virNetDaemon *virNetDaemonPtr; =20 -typedef struct _virNetServer virNetServer; -typedef virNetServer *virNetServerPtr; - typedef struct _virNetServerService virNetServerService; typedef virNetServerService *virNetServerServicePtr; =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list