From nobody Sun May 5 00:56:31 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 1548083610145697.4668371438686; Mon, 21 Jan 2019 07:13:30 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id BAF3687638; Mon, 21 Jan 2019 15:13:26 +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 7C0EB68B21; Mon, 21 Jan 2019 15:13:26 +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 254CC3F602; Mon, 21 Jan 2019 15:13:26 +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 x0LFDOQk024422 for ; Mon, 21 Jan 2019 10:13:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id AE27C1A7D6; Mon, 21 Jan 2019 15:13:24 +0000 (UTC) Received: from trick.home.annexia.org (ovpn-117-203.ams2.redhat.com [10.36.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33A161A7D4 for ; Mon, 21 Jan 2019 15:13:24 +0000 (UTC) From: "Richard W.M. Jones" To: libvir-list@redhat.com Date: Mon, 21 Jan 2019 15:13:20 +0000 Message-Id: <20190121151321.6259-2-rjones@redhat.com> In-Reply-To: <20190121151321.6259-1-rjones@redhat.com> References: <20190121151321.6259-1-rjones@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] nwfilter: Fix pointer. 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-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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 21 Jan 2019 15:13:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" GCC 9 complains: nwfilter/nwfilter_dhcpsnoop.c: In function 'virNWFilterDHCPSnoopThread': nwfilter/nwfilter_dhcpsnoop.c:1456:31: error: converting a packed 'virNWFil= terSnoopEthHdrPtr' {aka 'struct _virNWFilterSnoopEthHdr *'} pointer (alignm= ent 1) to 'const u_char *' {aka 'const unsigned char *'} (alignment 8) may = result in an unaligned pointer value [-Werror=3Daddress-of-packed-member] 1456 | (const u_char **)&packet); | ^ nwfilter/nwfilter_dhcpsnoop.c:183:8: note: defined here 183 | struct _virNWFilterSnoopEthHdr { | ^~~~~~~~~~~~~~~~~~~~~~~ However it seems like there's more going on here than just an enhanced GCC warning. The function pcap_next_ex is documented as: the pointer pointed to by the pkt_data argument is set to point to the data in the packet We are passing a struct here rather than a pointer. I changed the code to pass a pointer instead. --- src/nwfilter/nwfilter_dhcpsnoop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 58f0057c3f..45873a542c 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1335,7 +1335,7 @@ virNWFilterDHCPSnoopThread(void *req0) { virNWFilterSnoopReqPtr req =3D req0; struct pcap_pkthdr *hdr; - virNWFilterSnoopEthHdrPtr packet; + const virNWFilterSnoopEthHdrPtr *packetPtr; int ifindex =3D 0; int errcount =3D 0; int tmp =3D -1, rv, n, pollTo; @@ -1453,7 +1453,7 @@ virNWFilterDHCPSnoopThread(void *req0) n--; =20 rv =3D pcap_next_ex(pcapConf[i].handle, &hdr, - (const u_char **)&packet); + (const u_char **)&packetPtr); =20 if (rv < 0) { /* error reading from socket */ @@ -1530,7 +1530,7 @@ virNWFilterDHCPSnoopThread(void *req0) continue; } =20 - if (virNWFilterSnoopDHCPDecodeJobSubmit(worker, packet, + if (virNWFilterSnoopDHCPDecodeJobSubmit(worker, *packetPtr, hdr->caplen, pcapConf[i].dir, &pcapConf[i].qCtr) <= 0) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 00:56:31 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 1548083615516384.64716098895485; Mon, 21 Jan 2019 07:13:35 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 12948DB935; Mon, 21 Jan 2019 15:13:33 +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 C16B8104813D; Mon, 21 Jan 2019 15:13:32 +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 6E3F2180339C; Mon, 21 Jan 2019 15:13:32 +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 x0LFDSnp024433 for ; Mon, 21 Jan 2019 10:13:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5E85E19747; Mon, 21 Jan 2019 15:13:28 +0000 (UTC) Received: from trick.home.annexia.org (ovpn-117-203.ams2.redhat.com [10.36.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id D68421A92C for ; Mon, 21 Jan 2019 15:13:24 +0000 (UTC) From: "Richard W.M. Jones" To: libvir-list@redhat.com Date: Mon, 21 Jan 2019 15:13:21 +0000 Message-Id: <20190121151321.6259-3-rjones@redhat.com> In-Reply-To: <20190121151321.6259-1-rjones@redhat.com> References: <20190121151321.6259-1-rjones@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] tests: Avoid "jump skips variable initialization" with GCC 9. 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-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 21 Jan 2019 15:13:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" GCC 9 gives pages of errors like: qemumonitorjsontest.c: In function 'mymain': qemumonitorjsontest.c:2904:9: error: jump skips variable initialization [-W= error=3Djump-misses-init] 2904 | goto cleanup; | ^~~~ qemumonitorjsontest.c:3111:2: note: label 'cleanup' defined here 3111 | cleanup: | ^~~~~~~ qemumonitorjsontest.c:2920:54: note: '({anonymous})' declared here 2920 | simpleFunc =3D (testQemuMonitorJSONSimpleFuncData) {.xmlopt =3D= driver.xmlopt, \ | ^ qemumonitorjsontest.c:3008:5: note: in expansion of macro 'DO_TEST_GEN' 3008 | DO_TEST_GEN(qemuMonitorJSONBlockdevMediumInsert); | ^~~~~~~~~~~ By moving the cleanup section up near the top of the function we can avoid this. I think a better way might be to disable the warning. --- tests/qemumonitorjsontest.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 1a8a31717f..299c5f0cbe 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2900,8 +2900,12 @@ mymain(void) =20 if (!(qapiData.schema =3D testQEMUSchemaLoad())) { VIR_TEST_VERBOSE("failed to load qapi schema\n"); - ret =3D -1; - goto cleanup; + cleanup: + VIR_FREE(metaschemastr); + virJSONValueFree(metaschema); + virHashFree(qapiData.schema); + qemuTestDriverFree(&driver); + return -1; } =20 #define DO_TEST(name) \ @@ -3098,7 +3102,6 @@ mymain(void) if (!(metaschema =3D testQEMUSchemaGetLatest()) || !(metaschemastr =3D virJSONValueToString(metaschema, false))) { VIR_TEST_VERBOSE("failed to load latest qapi schema\n"); - ret =3D -1; goto cleanup; } =20 @@ -3108,7 +3111,6 @@ mymain(void) =20 #undef DO_TEST_QAPI_SCHEMA =20 - cleanup: VIR_FREE(metaschemastr); virJSONValueFree(metaschema); virHashFree(qapiData.schema); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list