From nobody Thu May 2 13:46:08 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517499616139367.2366360450212; Thu, 1 Feb 2018 07:40:16 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 4642C4F1C9; Thu, 1 Feb 2018 15:40:14 +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 0982B5C3F8; Thu, 1 Feb 2018 15:40:14 +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 BAF913FC73; Thu, 1 Feb 2018 15:40:13 +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 w11Fa2pG015115 for ; Thu, 1 Feb 2018 10:36:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4386160A9A; Thu, 1 Feb 2018 15:36:02 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B1BA60A9F; Thu, 1 Feb 2018 15:36:00 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 1 Feb 2018 15:35:50 +0000 Message-Id: <20180201153552.20047-2-berrange@redhat.com> In-Reply-To: <20180201153552.20047-1-berrange@redhat.com> References: <20180201153552.20047-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] tests: validate private data / pre / post exec hooks for RPC APIs 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: , Content-Type: text/plain; charset="utf-8" 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 01 Feb 2018 15:40:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Validate that the virNetServer(Client) RPC APIs are processing the private data callbacks correctly by passing in non-NULL pointers. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- .../virnetdaemondata/input-data-admin-nomdns.json | 12 ++-- .../input-data-admin-server-names.json | 12 ++-- .../virnetdaemondata/input-data-anon-clients.json | 6 +- .../input-data-client-auth-pending-failure.json | 3 +- .../input-data-client-auth-pending.json | 6 +- tests/virnetdaemondata/input-data-client-ids.json | 6 +- .../input-data-client-timestamp.json | 6 +- .../input-data-initial-nomdns.json | 6 +- tests/virnetdaemondata/input-data-initial.json | 6 +- .../input-data-no-keepalive-required.json | 12 ++-- .../virnetdaemondata/output-data-admin-nomdns.json | 12 ++-- .../output-data-admin-server-names.json | 12 ++-- .../virnetdaemondata/output-data-anon-clients.json | 6 +- .../output-data-client-auth-pending.json | 6 +- tests/virnetdaemondata/output-data-client-ids.json | 6 +- .../output-data-client-timestamp.json | 6 +- .../output-data-initial-nomdns.json | 6 +- tests/virnetdaemondata/output-data-initial.json | 6 +- .../output-data-no-keepalive-required.json | 12 ++-- tests/virnetdaemontest.c | 71 ++++++++++++++++++= +--- tests/virnetserverclienttest.c | 22 ++++++- 21 files changed, 183 insertions(+), 57 deletions(-) diff --git a/tests/virnetdaemondata/input-data-admin-nomdns.json b/tests/vi= rnetdaemondata/input-data-admin-nomdns.json index 449bcc9b25..985ea4b434 100644 --- a/tests/virnetdaemondata/input-data-admin-nomdns.json +++ b/tests/virnetdaemondata/input-data-admin-nomdns.json @@ -46,7 +46,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -57,7 +58,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] }, @@ -107,7 +109,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -118,7 +121,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/input-data-admin-server-names.json b/te= sts/virnetdaemondata/input-data-admin-server-names.json index 3afe16fad0..99515c5f12 100644 --- a/tests/virnetdaemondata/input-data-admin-server-names.json +++ b/tests/virnetdaemondata/input-data-admin-server-names.json @@ -48,7 +48,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -59,7 +60,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] }, @@ -110,7 +112,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -121,7 +124,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/input-data-anon-clients.json b/tests/vi= rnetdaemondata/input-data-anon-clients.json index 8a51ff53d6..8058fe0a43 100644 --- a/tests/virnetdaemondata/input-data-anon-clients.json +++ b/tests/virnetdaemondata/input-data-anon-clients.json @@ -45,7 +45,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -56,7 +57,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/input-data-client-auth-pending-failure.= json b/tests/virnetdaemondata/input-data-client-auth-pending-failure.json index 7d4ef6438d..9c33d92e08 100644 --- a/tests/virnetdaemondata/input-data-client-auth-pending-failure.json +++ b/tests/virnetdaemondata/input-data-client-auth-pending-failure.json @@ -36,7 +36,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, ] } diff --git a/tests/virnetdaemondata/input-data-client-auth-pending.json b/t= ests/virnetdaemondata/input-data-client-auth-pending.json index ae85253b53..56dd2d85d6 100644 --- a/tests/virnetdaemondata/input-data-client-auth-pending.json +++ b/tests/virnetdaemondata/input-data-client-auth-pending.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 3, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/input-data-client-ids.json b/tests/virn= etdaemondata/input-data-client-ids.json index 7caa2ccd57..c94a538b13 100644 --- a/tests/virnetdaemondata/input-data-client-ids.json +++ b/tests/virnetdaemondata/input-data-client-ids.json @@ -48,7 +48,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 3, @@ -60,7 +61,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/input-data-client-timestamp.json b/test= s/virnetdaemondata/input-data-client-timestamp.json index d069997a14..ee2b2357be 100644 --- a/tests/virnetdaemondata/input-data-client-timestamp.json +++ b/tests/virnetdaemondata/input-data-client-timestamp.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/input-data-initial-nomdns.json b/tests/= virnetdaemondata/input-data-initial-nomdns.json index 02bb427487..6cf70d96e8 100644 --- a/tests/virnetdaemondata/input-data-initial-nomdns.json +++ b/tests/virnetdaemondata/input-data-initial-nomdns.json @@ -44,7 +44,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -55,7 +56,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/input-data-initial.json b/tests/virnetd= aemondata/input-data-initial.json index 795622535b..5bb09ed36b 100644 --- a/tests/virnetdaemondata/input-data-initial.json +++ b/tests/virnetdaemondata/input-data-initial.json @@ -45,7 +45,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -56,7 +57,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/input-data-no-keepalive-required.json b= /tests/virnetdaemondata/input-data-no-keepalive-required.json index df282edd6e..1ed9ac2c7c 100644 --- a/tests/virnetdaemondata/input-data-no-keepalive-required.json +++ b/tests/virnetdaemondata/input-data-no-keepalive-required.json @@ -45,7 +45,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -56,7 +57,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] }, @@ -105,7 +107,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "auth": 2, @@ -116,7 +119,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-admin-nomdns.json b/tests/v= irnetdaemondata/output-data-admin-nomdns.json index d6d02163e2..04cb5e6bb3 100644 --- a/tests/virnetdaemondata/output-data-admin-nomdns.json +++ b/tests/virnetdaemondata/output-data-admin-nomdns.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] }, @@ -115,7 +117,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -128,7 +131,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-admin-server-names.json b/t= ests/virnetdaemondata/output-data-admin-server-names.json index d6d02163e2..04cb5e6bb3 100644 --- a/tests/virnetdaemondata/output-data-admin-server-names.json +++ b/tests/virnetdaemondata/output-data-admin-server-names.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] }, @@ -115,7 +117,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -128,7 +131,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-anon-clients.json b/tests/v= irnetdaemondata/output-data-anon-clients.json index cb6005bfe6..49fe89be48 100644 --- a/tests/virnetdaemondata/output-data-anon-clients.json +++ b/tests/virnetdaemondata/output-data-anon-clients.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-client-auth-pending.json b/= tests/virnetdaemondata/output-data-client-auth-pending.json index 5720ea9b71..0675404e6c 100644 --- a/tests/virnetdaemondata/output-data-client-auth-pending.json +++ b/tests/virnetdaemondata/output-data-client-auth-pending.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 3, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-client-ids.json b/tests/vir= netdaemondata/output-data-client-ids.json index 2b1663d4f8..90c3383a93 100644 --- a/tests/virnetdaemondata/output-data-client-ids.json +++ b/tests/virnetdaemondata/output-data-client-ids.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 3, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-client-timestamp.json b/tes= ts/virnetdaemondata/output-data-client-timestamp.json index e8c8e9a991..9cfb069793 100644 --- a/tests/virnetdaemondata/output-data-client-timestamp.json +++ b/tests/virnetdaemondata/output-data-client-timestamp.json @@ -50,7 +50,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -64,7 +65,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-initial-nomdns.json b/tests= /virnetdaemondata/output-data-initial-nomdns.json index 167aef8d29..916297c59d 100644 --- a/tests/virnetdaemondata/output-data-initial-nomdns.json +++ b/tests/virnetdaemondata/output-data-initial-nomdns.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-initial.json b/tests/virnet= daemondata/output-data-initial.json index 3281e868d7..5ed03472d6 100644 --- a/tests/virnetdaemondata/output-data-initial.json +++ b/tests/virnetdaemondata/output-data-initial.json @@ -50,7 +50,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -63,7 +64,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemondata/output-data-no-keepalive-required.json = b/tests/virnetdaemondata/output-data-no-keepalive-required.json index d6d02163e2..04cb5e6bb3 100644 --- a/tests/virnetdaemondata/output-data-no-keepalive-required.json +++ b/tests/virnetdaemondata/output-data-no-keepalive-required.json @@ -49,7 +49,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -62,7 +63,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] }, @@ -115,7 +117,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 }, { "id": 2, @@ -128,7 +131,8 @@ "errfd": -1, "pid": -1, "isClient": true - } + }, + "privateData": 1729 } ] } diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c index 435513d314..8cda06b197 100644 --- a/tests/virnetdaemontest.c +++ b/tests/virnetdaemontest.c @@ -27,6 +27,54 @@ #define VIR_FROM_THIS VIR_FROM_RPC =20 #if defined(HAVE_SOCKETPAIR) && defined(WITH_YAJL) +struct testClientPriv { + int magic; +}; + +static void *testClientNew(virNetServerClientPtr client ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + struct testClientPriv *priv; + + if (VIR_ALLOC(priv) < 0) + return NULL; + + priv->magic =3D 1729; + + return priv; +} + +static virJSONValuePtr testClientPreExec(virNetServerClientPtr client ATTR= IBUTE_UNUSED, + void *data) +{ + struct testClientPriv *priv =3D data; + + return virJSONValueNewNumberInt(priv->magic); +} + + +static void *testClientNewPostExec(virNetServerClientPtr client, + virJSONValuePtr object, + void *opaque) +{ + int magic; + + if (virJSONValueGetNumberInt(object, &magic) < 0) { + return NULL; + } + + if (magic !=3D 1729) { + return NULL; + } + + return testClientNew(client, opaque); +} + +static void testClientFree(void *opaque) +{ + VIR_FREE(opaque); +} + static virNetServerPtr testCreateServer(const char *server_name, const char *host, int family) { @@ -53,9 +101,9 @@ testCreateServer(const char *server_name, const char *ho= st, int family) 10, 50, 5, 100, 10, 120, 5, mdns_group, - NULL, - NULL, - NULL, + testClientNew, + testClientPreExec, + testClientFree, NULL))) goto error; =20 @@ -101,7 +149,10 @@ testCreateServer(const char *server_name, const char *= host, int family) # ifdef WITH_GNUTLS NULL, # endif - NULL, NULL, NULL, NULL))) + testClientNew, + testClientPreExec, + testClientFree, + NULL))) goto error; =20 if (!(cln2 =3D virNetServerClientNew(virNetServerNextClientID(srv), @@ -112,7 +163,10 @@ testCreateServer(const char *server_name, const char *= host, int family) # ifdef WITH_GNUTLS NULL, # endif - NULL, NULL, NULL, NULL))) + testClientNew, + testClientPreExec, + testClientFree, + NULL))) goto error; =20 if (virNetServerAddClient(srv, cln1) < 0) @@ -206,8 +260,11 @@ testNewServerPostExecRestart(virNetDaemonPtr dmn ATTRI= BUTE_UNUSED, if (STREQ(data->serverNames[i], name)) { return virNetServerNewPostExecRestart(object, name, - NULL, NULL, NULL, - NULL, NULL); + NULL, + testClientNewPostExec, + testClientPreExec, + testClientFree, + NULL); } } =20 diff --git a/tests/virnetserverclienttest.c b/tests/virnetserverclienttest.c index 96b69b3e45..351ba9f4c7 100644 --- a/tests/virnetserverclienttest.c +++ b/tests/virnetserverclienttest.c @@ -27,6 +27,23 @@ #define VIR_FROM_THIS VIR_FROM_RPC =20 #ifdef HAVE_SOCKETPAIR + +static void *testClientNew(virNetServerClientPtr client ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + char *dummy; + + if (VIR_ALLOC(dummy) < 0) + return NULL; + + return dummy; +} + +static void testClientFree(void *opaque) +{ + VIR_FREE(opaque); +} + static int testIdentity(const void *opaque ATTRIBUTE_UNUSED) { int sv[2]; @@ -56,7 +73,10 @@ static int testIdentity(const void *opaque ATTRIBUTE_UNU= SED) # ifdef WITH_GNUTLS NULL, # endif - NULL, NULL, NULL, NULL))) { + testClientNew, + NULL, + testClientFree, + NULL))) { virDispatchError(NULL); goto cleanup; } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 13:46:08 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517499384413380.95853990898297; Thu, 1 Feb 2018 07:36:24 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id D0839780F4; Thu, 1 Feb 2018 15:36:22 +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 9FA6E61348; Thu, 1 Feb 2018 15:36:22 +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 47F743FC71; Thu, 1 Feb 2018 15:36:22 +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 w11Fa5ww015126 for ; Thu, 1 Feb 2018 10:36:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0B33660C1D; Thu, 1 Feb 2018 15:36:05 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39AC860A9A; Thu, 1 Feb 2018 15:36:02 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 1 Feb 2018 15:35:51 +0000 Message-Id: <20180201153552.20047-3-berrange@redhat.com> In-Reply-To: <20180201153552.20047-1-berrange@redhat.com> References: <20180201153552.20047-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] rpc: assume private data callbacks are always non-NULL 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: , Content-Type: text/plain; charset="utf-8" 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 01 Feb 2018 15:36:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Since we annotate the APIs are having non-NULL parameters, we can remove the checks for NULL in the code too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/rpc/virnetserverclient.c | 47 ++++++++++++++++++++--------------------= ---- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index d81a3892ff..388514946b 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -466,14 +466,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned = long long id, now))) return NULL; =20 - if (privNew) { - if (!(client->privateData =3D privNew(client, privOpaque))) { - virObjectUnref(client); - return NULL; - } - client->privateDataFreeFunc =3D privFree; - client->privateDataPreExecRestart =3D privPreExecRestart; + if (!(client->privateData =3D privNew(client, privOpaque))) { + virObjectUnref(client); + return NULL; } + client->privateDataFreeFunc =3D privFree; + client->privateDataPreExecRestart =3D privPreExecRestart; =20 return client; } @@ -580,18 +578,18 @@ virNetServerClientPtr virNetServerClientNewPostExecRe= start(virNetServerPtr srv, } virObjectUnref(sock); =20 - if (privNew) { - if (!(child =3D virJSONValueObjectGet(object, "privateData"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing privateData field in JSON state docu= ment")); - goto error; - } - if (!(client->privateData =3D privNew(client, child, privOpaque))) - goto error; - client->privateDataFreeFunc =3D privFree; - client->privateDataPreExecRestart =3D privPreExecRestart; + if (!(child =3D virJSONValueObjectGet(object, "privateData"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing privateData field in JSON state document= ")); + goto error; } =20 + if (!(client->privateData =3D privNew(client, child, privOpaque))) + goto error; + + client->privateDataFreeFunc =3D privFree; + client->privateDataPreExecRestart =3D privPreExecRestart; + =20 return client; =20 @@ -637,14 +635,12 @@ virJSONValuePtr virNetServerClientPreExecRestart(virN= etServerClientPtr client) goto error; } =20 - if (client->privateData && client->privateDataPreExecRestart) { - if (!(child =3D client->privateDataPreExecRestart(client, client->= privateData))) - goto error; + if (!(child =3D client->privateDataPreExecRestart(client, client->priv= ateData))) + goto error; =20 - if (virJSONValueObjectAppend(object, "privateData", child) < 0) { - virJSONValueFree(child); - goto error; - } + if (virJSONValueObjectAppend(object, "privateData", child) < 0) { + virJSONValueFree(child); + goto error; } =20 virObjectUnlock(client); @@ -989,8 +985,7 @@ void virNetServerClientDispose(void *obj) PROBE(RPC_SERVER_CLIENT_DISPOSE, "client=3D%p", client); =20 - if (client->privateData && - client->privateDataFreeFunc) + if (client->privateData) client->privateDataFreeFunc(client->privateData); =20 virObjectUnref(client->identity); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 13:46:08 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517499624309414.49275737870346; Thu, 1 Feb 2018 07:40:24 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id D581A859FA; Thu, 1 Feb 2018 15:40:21 +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 9941C17CC0; Thu, 1 Feb 2018 15:40:21 +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 382E318033D9; Thu, 1 Feb 2018 15:40:21 +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 w11Fa7D0015142 for ; Thu, 1 Feb 2018 10:36:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 17FCA60A9F; Thu, 1 Feb 2018 15:36:07 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 785256090B; Thu, 1 Feb 2018 15:36:05 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 1 Feb 2018 15:35:52 +0000 Message-Id: <20180201153552.20047-4-berrange@redhat.com> In-Reply-To: <20180201153552.20047-1-berrange@redhat.com> References: <20180201153552.20047-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] rpc: fix non-NULL annotations when GNUTLS is disabled 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: , Content-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 01 Feb 2018 15:40:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The position of various parameters changes depending on the WITH_GNUTLS macro. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/rpc/virnetserverclient.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h index 4a0d3cc25e..1a939ad4e1 100644 --- a/src/rpc/virnetserverclient.h +++ b/src/rpc/virnetserverclient.h @@ -73,7 +73,11 @@ virNetServerClientPtr virNetServerClientNew(unsigned lon= g long id, virNetServerClientPrivPreExecR= estart privPreExecRestart, virFreeCallback privFree, void *privOpaque) +# ifdef WITH_GNUTLS ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(7) ATTRIBUTE_NONNULL(9); +# else + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(6) ATTRIBUTE_NONNULL(8); +# endif =20 virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr= srv, virJSONValuePtr= object, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list