1From 4e1963a812f2c1777ba5d56ea9e939a3e40a0496 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3 <zboszor@gmail.com>
4Date: Sat, 28 Aug 2021 15:38:40 +0200
5Subject: [PATCH] Fix a build  error with Xorg master
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Use xf86ReturnOptValBool() in get_bool_option() instead of
11options[option_index].value.bool to fix a compiler error with
12current Xorg xserver master branch.
13
14Also use xf86GetOptValInteger() in get_int_option() and
15xf86GetOptValString() in get_str_option() for consistency.
16
17The change causes a slight performance drop during option parsing
18because the passed-in index_value is no longer used as an index
19into the options array.
20
21Instead, it's used as a token now for the standard option getter
22functions which works since the index_value to the get_*_option()
23functions are identical to the value of options[n].token in the
24passed-in OptionInfoRec array.
25
26Also rename "int option_index" to "int token" for clarity in all
27three functions.
28
29Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
30
31Downloaded from upstream commit
32https://gitlab.freedesktop.org/xorg/driver/xf86-video-qxl/-/commit/4e1963a812f2c1777ba5d56ea9e939a3e40a0496
33
34Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
35---
36 src/qxl_option_helpers.c | 13 +++++++------
37 src/qxl_option_helpers.h |  6 +++---
38 2 files changed, 10 insertions(+), 9 deletions(-)
39
40diff --git a/src/qxl_option_helpers.c b/src/qxl_option_helpers.c
41index 2aba677..7707b7c 100644
42--- a/src/qxl_option_helpers.c
43+++ b/src/qxl_option_helpers.c
44@@ -10,31 +10,32 @@
45
46 #include "qxl_option_helpers.h"
47
48-int get_int_option(OptionInfoPtr options, int option_index,
49+int get_int_option(OptionInfoPtr options, int token,
50                    const char *env_name)
51 {
52+    int value;
53     if (env_name && getenv(env_name)) {
54         return atoi(getenv(env_name));
55     }
56-    return options[option_index].value.num;
57+    return xf86GetOptValInteger(options, token, &value) ? value : 0;
58 }
59
60-const char *get_str_option(OptionInfoPtr options, int option_index,
61+const char *get_str_option(OptionInfoPtr options, int token,
62                            const char *env_name)
63 {
64     if (getenv(env_name)) {
65         return getenv(env_name);
66     }
67-    return options[option_index].value.str;
68+    return xf86GetOptValString(options, token);
69 }
70
71-int get_bool_option(OptionInfoPtr options, int option_index,
72+int get_bool_option(OptionInfoPtr options, int token,
73                      const char *env_name)
74 {
75     const char* value = getenv(env_name);
76
77     if (!value) {
78-        return options[option_index].value.bool;
79+        return xf86ReturnOptValBool(options, token, FALSE);
80     }
81     if (strcmp(value, "0") == 0 ||
82         strcasecmp(value, "off") == 0 ||
83diff --git a/src/qxl_option_helpers.h b/src/qxl_option_helpers.h
84index 7c54c72..66d0a17 100644
85--- a/src/qxl_option_helpers.h
86+++ b/src/qxl_option_helpers.h
87@@ -4,13 +4,13 @@
88 #include <xf86Crtc.h>
89 #include <xf86Opt.h>
90
91-int get_int_option(OptionInfoPtr options, int option_index,
92+int get_int_option(OptionInfoPtr options, int token,
93                    const char *env_name);
94
95-const char *get_str_option(OptionInfoPtr options, int option_index,
96+const char *get_str_option(OptionInfoPtr options, int token,
97                            const char *env_name);
98
99-int get_bool_option(OptionInfoPtr options, int option_index,
100+int get_bool_option(OptionInfoPtr options, int token,
101                      const char *env_name);
102
103 #endif // OPTION_HELPERS_H
104--
105GitLab
106
107