From nobody Thu May 2 02:53:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568039939; cv=none; d=zoho.com; s=zohoarc; b=GLXH5YFKFVZxG6Pg60X6dN6V+eHoaN31n0xPTM3ZBnD2mfcCZbHMvouy3OvG7lJ2AU1c/CcgZu4x1k2v+vTxSRXFUVnD+Bb1P0yws7MPpb6irrxaA2HARL5EL0pJLgYBKgZGuRoV8TIIMuaSHE/nMrxofCSA0AU9FaFjwPYFD6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568039939; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=VxW2+zpDCMXYGl8nghL7Q9Cmw4sNkEZu5LDJSLRVWZA=; b=cgBsjZ1AfTc875KXDGVpUUua3Yvz6vRtl6blpHmKL5VW9elgx56GD0Xqd+CEyu0jqwrHmUQZEYdB5PK/l1W5DgzieBQCxQWKWLNUnYkMbWdr6WnKo2QlPymKuqC3rK+fkyH8+8Su3Si4glmfHCUnCxq5FCNh4t55YNjrqIv3BM0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568039939757230.224675988674; Mon, 9 Sep 2019 07:38:59 -0700 (PDT) Received: from localhost ([::1]:57484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7Kod-0004W3-3y for importer@patchew.org; Mon, 09 Sep 2019 10:38:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42547) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7Kne-0003iF-Bm for qemu-devel@nongnu.org; Mon, 09 Sep 2019 10:37:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7Knd-0003SB-B6 for qemu-devel@nongnu.org; Mon, 09 Sep 2019 10:37:50 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:45310) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i7Knd-0003PQ-4U for qemu-devel@nongnu.org; Mon, 09 Sep 2019 10:37:49 -0400 Received: by mail-wr1-x444.google.com with SMTP id l16so14083563wrv.12 for ; Mon, 09 Sep 2019 07:37:48 -0700 (PDT) Received: from localhost.localdomain ([2001:b07:6468:f312:4580:a289:2f55:eec1]) by smtp.gmail.com with ESMTPSA id d28sm16366179wrb.95.2019.09.09.07.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VxW2+zpDCMXYGl8nghL7Q9Cmw4sNkEZu5LDJSLRVWZA=; b=GR/kzt4YmsIG86zFvTZxZJKKJ7J9BMpxBzGC+OhRd72wwEz4Wbh6hbQdXbpROIWaHr dkz2uiwgPF3SE6G/tIKsTmJzsiWJRbwwP2OQJRPlZrnAJhqFTOxDNlK8fSuH6LeqXgLy hZPLkhPjCL7vjBab/mrHdmHxN1zJ/qP53VuB8Mg6cm+2Fa1vTNb4yIo9CXy71DOtDCe/ 1Chjx+gCeuXa7ioBt890ctlV23DlTKDrj8Ihi0ttEP6zzhxZhH6bLdH1U60b8CQzhLy1 zqnlnsYmaQ5Sbupk8GoL2W3D2zx2WoTlteTuGKqlJreENou3rQQzgmanO3ClhKDsaE1t r3VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=VxW2+zpDCMXYGl8nghL7Q9Cmw4sNkEZu5LDJSLRVWZA=; b=KBWa2jQ0OqZMtv2piOFtj9kKrsMJVwAjvNXzfBCmt6iSbcYS6LOWvJndHubdj69VYl NbwsjrBWo/tAFnzsApuIDBX9lPeABQfa9+4hv2PPs7LyRoFVzcb/dW4iBoSIJeb8njw+ 4/QN+BjnOl6bvSd8fjT0n9C2QtXXqYfMObTPC0En2RFiu7n8cuufhPttwyxlqu+KIJqY K8wdeIf2Lm+ghnS03oQoFWfftWHbu2F/eJKgfxDApr1vrV5k0oBU/SpZGtjBw0OeApa+ rp+5zN2j3EjWZJCom0GGge1MztdbtZ/UqJaef74U3NGyzbduQugMW3iqvttqNnk93HZD YXDw== X-Gm-Message-State: APjAAAXOBjh8zk7CCCo8ZI1G7fgWSvZWwyrwP8wBfZkvgtJoSH1ln2er CQjue4ZyVawTWZDxni6ixyCVW8CZVGM= X-Google-Smtp-Source: APXvYqxW5gnxZRT4M+DW5FohmvkgrsQDC8Z8eWUsCqoNOwqumvICWUYEUUMm/pfDRO4uApG8qg2DXw== X-Received: by 2002:a05:6000:108e:: with SMTP id y14mr18886065wrw.344.1568039866718; Mon, 09 Sep 2019 07:37:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 9 Sep 2019 16:37:32 +0200 Message-Id: <20190909143732.11322-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v2] test-char: fix AddressSanitizer failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , berrange@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The CharSocketServerTestConfig and CharSocketClientTestConfig objects escape after they are passed to g_test_add_data_func, but they cease existing after the scope that defines them is closed. Make them static to fix this issue. Fixes: e7b6ba4186f243f149b0d8cddc129fe681ba3912 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- tests/test-char.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/test-char.c b/tests/test-char.c index f3ebdffd87..d62de1b088 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -1355,6 +1355,18 @@ static void char_hotswap_test(void) g_free(chr_args); } =20 +static SocketAddress tcpaddr =3D { + .type =3D SOCKET_ADDRESS_TYPE_INET, + .u.inet.host =3D (char *)"127.0.0.1", + .u.inet.port =3D (char *)"0", +}; +#ifndef WIN32 +static SocketAddress unixaddr =3D { + .type =3D SOCKET_ADDRESS_TYPE_UNIX, + .u.q_unix.path =3D (char *)"test-char.sock", +}; +#endif + int main(int argc, char **argv) { bool has_ipv4, has_ipv6; @@ -1390,26 +1402,14 @@ int main(int argc, char **argv) g_test_add_func("/char/file-fifo", char_file_fifo_test); #endif =20 - SocketAddress tcpaddr =3D { - .type =3D SOCKET_ADDRESS_TYPE_INET, - .u.inet.host =3D (char *)"127.0.0.1", - .u.inet.port =3D (char *)"0", - }; -#ifndef WIN32 - SocketAddress unixaddr =3D { - .type =3D SOCKET_ADDRESS_TYPE_UNIX, - .u.q_unix.path =3D (char *)"test-char.sock", - }; -#endif - #define SOCKET_SERVER_TEST(name, addr) \ - CharSocketServerTestConfig server1 ## name =3D \ + static CharSocketServerTestConfig server1 ## name =3D \ { addr, false, false }; \ - CharSocketServerTestConfig server2 ## name =3D \ + static CharSocketServerTestConfig server2 ## name =3D \ { addr, true, false }; \ - CharSocketServerTestConfig server3 ## name =3D \ + static CharSocketServerTestConfig server3 ## name =3D \ { addr, false, true }; \ - CharSocketServerTestConfig server4 ## name =3D \ + static CharSocketServerTestConfig server4 ## name =3D \ { addr, true, true }; \ g_test_add_data_func("/char/socket/server/mainloop/" # name, \ &server1 ##name, char_socket_server_test); \ @@ -1421,17 +1421,17 @@ int main(int argc, char **argv) &server4 ##name, char_socket_server_test) =20 #define SOCKET_CLIENT_TEST(name, addr) \ - CharSocketClientTestConfig client1 ## name =3D \ + static CharSocketClientTestConfig client1 ## name =3D \ { addr, NULL, false, false }; \ - CharSocketClientTestConfig client2 ## name =3D \ + static CharSocketClientTestConfig client2 ## name =3D \ { addr, NULL, true, false }; \ - CharSocketClientTestConfig client3 ## name =3D \ + static CharSocketClientTestConfig client3 ## name =3D \ { addr, ",reconnect=3D1", false }; \ - CharSocketClientTestConfig client4 ## name =3D \ + static CharSocketClientTestConfig client4 ## name =3D \ { addr, ",reconnect=3D1", true }; \ - CharSocketClientTestConfig client5 ## name =3D \ + static CharSocketClientTestConfig client5 ## name =3D \ { addr, NULL, false, true }; \ - CharSocketClientTestConfig client6 ## name =3D \ + static CharSocketClientTestConfig client6 ## name =3D \ { addr, NULL, true, true }; \ g_test_add_data_func("/char/socket/client/mainloop/" # name, \ &client1 ##name, char_socket_client_test); \ --=20 2.21.0