[PATCH wayland 5/6] tests: Overly elaborate compiler warning workaround

Daniel Stone daniels at collabora.com
Wed Aug 29 06:17:14 UTC 2018


Clang will rightly point out that example_sockaddr_un in socket-test
will get discarded from the compilation unit as it is completely unused.
Put in a couple of lines which of no value other than stopping Clang
from complaining.

Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 tests/socket-test.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/socket-test.c b/tests/socket-test.c
index e9705628..8d39edce 100644
--- a/tests/socket-test.c
+++ b/tests/socket-test.c
@@ -42,7 +42,7 @@
  * See `man 7 unix`.
  */
 
-static const struct sockaddr_un example_sockaddr_un;
+static struct sockaddr_un example_sockaddr_un;
 
 #define TOO_LONG (1 + sizeof example_sockaddr_un.sun_path)
 
@@ -69,6 +69,11 @@ TEST(socket_path_overflow_client_connect)
 	d = wl_display_connect(path);
 	assert(d == NULL);
 	assert(errno == ENAMETOOLONG);
+
+	/* This is useless, but prevents a warning about example_sockaddr_un
+	 * being discarded from the compilation unit. */
+	strcpy(example_sockaddr_un.sun_path, "happy now clang?");
+	assert(example_sockaddr_un.sun_path[0] != '\0');
 }
 
 TEST(socket_path_overflow_server_create)
-- 
2.17.1



More information about the wayland-devel mailing list