Commit b67e514d authored by Povilas Kanapickas's avatar Povilas Kanapickas
Browse files

meson: Fix warnings when reading back and checking feature flags

Meson does not like comparing things of different types which is a
problem when reading back values of feature flags as they may contain
either false (bool) or 1 (string).

Since there is a strong reason why we use false when the feature does
not exist, we work around this issue by always converting the returned
value to int via to_int().

Fixes: xorg/xserver#1190

Signed-off-by: Povilas Kanapickas's avatarPovilas Kanapickas <>
parent b2a0de4f
......@@ -16,6 +16,15 @@ conf_data.set('HAVE_TYPEOF', cc.compiles('''
name: 'typeof()') ? '1' : false)
# For feature macros we're using either false (boolean) or '1', which correspond to the macro being
# not defined at all and defined to 1. This is to match autotools behavior and thus preserve
# backwards compatibility with all the existing code that uses #ifdef to check if feature is
# enabled. This ifdef would pass if the macro is defined to 0 which would silently break code
# in various places.
# As a complication when we read the configuration from conf_data back we get either string or
# bool. Meson does not like comparing things of different types so we always convert the returned
# value to an integer using to_int().
conf_data.set('MONOTONIC_CLOCK', cc.has_function('clock_gettime') and
#define _POSIX_C_SOURCE 200112L
......@@ -181,7 +190,7 @@ if cc.has_header_symbol('sys/socket.h', 'SCM_RIGHTS')
conf_data.set('XTRANS_SEND_FDS', '1')
if conf_data.get('HAVE_GETPEEREID') == false and conf_data.get('HAVE_GETPEERUCRED') == false
if conf_data.get('HAVE_GETPEEREID').to_int() == 0 and conf_data.get('HAVE_GETPEERUCRED').to_int() == 0
if not cc.has_header_symbol('sys/socket.h', 'SO_PEERCRED')
conf_data.set('NO_LOCAL_CLIENT_CRED', 1)
......@@ -21,32 +21,32 @@ srcs_os = [
# Wrapper code for missing C library functions. Note that conf_data contains either '1' or false.
srcs_libc = []
if conf_data.get('HAVE_REALLOCARRAY') == false
if conf_data.get('HAVE_REALLOCARRAY').to_int() == 0
srcs_libc += 'reallocarray.c'
if conf_data.get('HAVE_STRCASECMP') == false
if conf_data.get('HAVE_STRCASECMP').to_int() == 0
srcs_libc += 'strcasecmp.c'
if conf_data.get('HAVE_STRCASESTR') == false
if conf_data.get('HAVE_STRCASESTR').to_int() == 0
srcs_libc += 'strcasestr.c'
if conf_data.get('HAVE_STRLCAT') == false
if conf_data.get('HAVE_STRLCAT').to_int() == 0
srcs_libc += 'strlcat.c'
if conf_data.get('HAVE_STRLCPY') == false
if conf_data.get('HAVE_STRLCPY').to_int() == 0
srcs_libc += 'strlcpy.c'
if conf_data.get('HAVE_STRNDUP') == false
if conf_data.get('HAVE_STRNDUP').to_int() == 0
srcs_libc += 'strndup.c'
if conf_data.get('HAVE_TIMINGSAFE_MEMCMP') == false
if conf_data.get('HAVE_TIMINGSAFE_MEMCMP').to_int() == 0
srcs_libc += 'timingsafe_memcmp.c'
if conf_data.get('HAVE_POLL') == false
if conf_data.get('HAVE_POLL').to_int() == 0
srcs_os += 'xserver_poll.c'
if conf_data.get('BUSFAULT') != false
if conf_data.get('BUSFAULT').to_int() != 0
srcs_os += 'busfault.c'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment