virglrenderer: Fix build with clang

Fix warnigns seen with -Wembedded-directive -D_FORTIFY_SOURCE=2

(From OE-Core rev: 6e698bac55f785e84f52161cfab8fe6e764940cc)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Khem Raj
2023-12-01 10:33:53 -08:00
committed by Richard Purdie
parent a5ee86fd99
commit e0a7cccb95
2 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
From ea328b246d093477cf26a68b42e975aaaef6abad Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 28 Nov 2023 21:55:36 -0800
Subject: [PATCH] vtest: Fix undefined behavior with clang
This is seen when compiling with CC="clang -D_FORTIFY_SOURCE=2"
Move #ifdef outside of printf() call.
Fixes
| ../git/vtest/vtest_server.c:244:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
| 244 | #ifdef ENABLE_VENUS
| | ^
| ../git/vtest/vtest_server.c:246:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
| 246 | #endif
| | ^
Upstream-Status: Submitted [https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1309]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
vtest/vtest_server.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/vtest/vtest_server.c b/vtest/vtest_server.c
index 1ca7f74f..93d949d7 100644
--- a/vtest/vtest_server.c
+++ b/vtest/vtest_server.c
@@ -197,6 +197,12 @@ static void vtest_server_parse_args(int argc, char **argv)
/* getopt_long stores the option index here. */
int option_index = 0;
+#ifdef ENABLE_VENUS
+ char* ven = " [--venus]";
+#else
+ char* ven = "";
+#endif
+
do {
ret = getopt_long(argc, argv, "", long_options, &option_index);
@@ -244,10 +250,8 @@ static void vtest_server_parse_args(int argc, char **argv)
printf("Usage: %s [--no-fork] [--no-loop-or-fork] [--multi-clients] "
"[--use-glx] [--use-egl-surfaceless] [--use-gles] [--no-virgl]"
"[--rendernode <dev>] [--socket-path <path>] "
-#ifdef ENABLE_VENUS
- " [--venus]"
-#endif
- " [file]\n", argv[0]);
+ "%s"
+ " [file]\n", argv[0], ven);
exit(EXIT_FAILURE);
break;
}
--
2.43.0

View File

@@ -12,6 +12,7 @@ DEPENDS = "libdrm libepoxy virtual/egl virtual/libgbm"
SRCREV = "9c9d55ecbe502e0d71ee99529709efcca69aac42"
SRC_URI = "git://gitlab.freedesktop.org/virgl/virglrenderer.git;branch=main;protocol=https \
file://0001-meson.build-use-python3-directly-for-python.patch \
file://0001-vtest-Fix-undefined-behavior-with-clang.patch \
"
S = "${WORKDIR}/git"