summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/virglrenderer/virglrenderer/0001-vtest-Fix-undefined-behavior-with-clang.patch
blob: 48488d7be12143275a3d0ead9c3b355817f1be7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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