]> git.ipfire.org Git - thirdparty/util-linux.git/commit
meson: avoid int operation with non-int
authorThomas Weißschuh <thomas@t-8ch.de>
Mon, 9 Oct 2023 05:34:46 +0000 (07:34 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Mon, 9 Oct 2023 05:34:46 +0000 (07:34 +0200)
commit941e1d555cafdc56d36defc40c0d4ad9a18ed53b
tree4d132e669f888eb26c4b621a3fe793e5fd903c9b
parent762898e3fe469991be742216e573609142a0df99
meson: avoid int operation with non-int

`conf` as configuration_data() object can contain any datatype.
For `HAVE_FOO` variables this will be a `1` int to generate
`#define HAVE_FOO 1` or a `false` bool to generate `#undef HAVE_FOO`
in `conf.h`.

When retrieving and testing `HAVE_FOO` from `conf` it can be both types.
Newer versions of meson are unhappy about comparisions of int with
non-int

    ../meson.build:734: DEPRECATION: Project uses feature that was always broken, and is now deprecated since '1.2.0': int operations with non-int. It is not commutative and only worked because of leaky Python abstractions.

    WARNING: Broken features used:
     * 1.2.0: {'int operations with non-int'}

As both `int` and `bool` support a `.to_string()` method, we can use
that to convert them into a well-known type and compare that.

Unfortunately meson does not implement a way to determine the type of a
value.
A method `int.to_int()` would also have worked but does not exist.

This broken feature was actually first recognized in util-linux.
See #2312 and https://github.com/mesonbuild/meson/pull/11879.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
meson.build