Commit Graph

26626 Commits

Author SHA1 Message Date
Robert Ancell
4ba188c906 portal: Rename function to not be flatpak specific
It will also read snap information
2022-11-24 05:38:32 +01:00
Simon McVittie
78d0ac4237 Merge branch 'valgrind-fd-fun' into 'main'
gspawn: Ignore invalid FDs when using safe_fdwalk()

See merge request GNOME/glib!3076
2022-11-23 17:34:05 +00:00
Simon McVittie
a241226f2e Merge branch 'gdbus-tests-isolate-dirs' into 'main'
tests: Add G_TEST_OPTION_ISOLATE_DIRS to almost all gdbus tests

See merge request GNOME/glib!3088
2022-11-23 17:20:44 +00:00
Philip Withnall
7248c88b2c Merge branch 'mkenum' into 'main'
meson: Use gnome.mkenum_simple()

See merge request GNOME/glib!2917
2022-11-23 13:29:59 +00:00
Xavier Claessens
756b424cce meson: Use gnome.mkenum_simple()
Meson now uses find_program() to get glib-mkenum from glib instead of
from system. That was already fixed at least in >=0.60 which is our
current minimum requirement.
2022-11-23 08:02:34 -05:00
Xavier Claessens
6dd5c5002a Merge branch 'wip/pwithnall/meson-0.64' into 'main'
build: Bump Meson dependency to 0.64.0

See merge request GNOME/glib!3077
2022-11-23 11:48:51 +00:00
Philip Withnall
fd27c8dc6e tests: Add G_TEST_OPTION_ISOLATE_DIRS to almost all gdbus tests
This is a spiritual follow-up to commit 8cff531520, which
added `G_TEST_OPTION_ISOLATE_DIRS` to the `gdbus-connection-flush` test
to avoid its D-Bus cookie lock file from being erroneously deleted by
other tests running in parallel.

The same failure mode could affect any of the other D-Bus tests which
connect to a bus. As an easy fix, enable `G_TEST_OPTION_ISOLATE_DIRS`
for all of them.

The only test it’s not (yet) enabled for is `gdbus-address-get-session`
as that messes around with `XDG_RUNTIME_DIR` to test finding the session
bus. It might be possible to use `G_TEST_OPTION_ISOLATE_DIRS` with it,
but that would take longer than I have right now.

In any case, the more tests (which try to connect to a bus) that this is
enabled for, the lower the chances of spurious test failure due to them
conflicting over shared resources.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-23 11:15:20 +00:00
Philip Withnall
19353017a7 build: Use fs.copyfile() instead of configure_file()
Because Meson complains about using `configure_file(copy: true)`.

Includes improvements by Xavier Claessens.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-23 10:40:32 +00:00
Philip Withnall
7e3e591d43 build: Don’t define redundant built-in variables in pkgconfig calls
This is deprecated since Meson 0.62.0, since Meson does this
automatically for us.

This fixes a Meson configure warning.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-23 10:39:58 +00:00
Philip Withnall
91f14cd058 build: Bump Meson dependency to 0.64.0
It will fix dependency ordering issues found in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2917#note_1559190.

As per `docs/meson-version.md`, we can depend on Meson ≤0.64.0 now as
it’s in Debian Testing.

The FreeBSD runners have to be changed to explicitly install the right
version of Meson using `pip3`, as the system-installed version is not
quite new enough. See
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3077#note_1596257.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: !2917
2022-11-23 10:39:13 +00:00
Marco Trevisan
ad755e7489 Merge branch 'c-cxx-std-versions' into 'main'
Expose C and C++ standard versions and add macros to check them

See merge request GNOME/glib!2895
2022-11-22 21:10:34 +00:00
Marco Trevisan
b7344e374b Merge branch '2786-deprecate-options' into 'main'
build: Deprecate -Druntime_libdir option

Closes #2786

See merge request GNOME/glib!3087
2022-11-22 18:54:22 +00:00
Marco Trevisan
291ca47bd5 Merge branch 'wait-for-nothing' into 'main'
tests: Remove a manual timeout from desktop-app-info test

See merge request GNOME/glib!3083
2022-11-22 17:58:04 +00:00
Marco Trevisan
8fba287c81 Merge branch 'wip/pwithnall/2777-zerosize' into 'main'
gio: Change content type of zero-sized files to application/x-zerosize

Closes #2777

See merge request GNOME/glib!3053
2022-11-22 17:52:47 +00:00
Marco Trevisan
1e5178b002 Merge branch '2793-clear-annotations' into 'main'
gmem: Fix introspection annotations for g_clear_pointer() and g_clear_fd()

Closes #2793

See merge request GNOME/glib!3085
2022-11-22 17:27:34 +00:00
Marco Trevisan (Treviño)
ff49707501 gmacros: Use G_C_STD_CHECK_VERSION to define C-std dependent items 2022-11-22 17:45:56 +01:00
Philip Withnall
e71ecc8771 build: Remove deprecated -Diconv option
It was deprecated in GLib 2.74, so we can now remove it.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2786
2022-11-22 16:32:42 +00:00
Philip Withnall
8d77591d89 build: Deprecate -Druntime_libdir option
It’s been broken since we ported to Meson and nobody has complained, so
let’s deprecate it this cycle and remove it in GLib ≥ 2.78.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2786
2022-11-22 16:31:28 +00:00
Philip Withnall
e535f22b08 gmem: Fix introspection annotations for g_clear_pointer() and g_clear_fd()
They were mixing up `(optional)` and `(nullable)`, and didn’t correctly
annotate the arguments as `(inout)` or `(transfer full)`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2793
2022-11-22 16:25:39 +00:00
Marco Trevisan (Treviño)
633561ada2 macros: Add a generic way to get and check the supported C standard
Try to get the value of __STDC_VERSION__ if supported, if not just
fallback to the oldest standard that any compiler should handle.
2022-11-22 17:23:14 +01:00
Marco Trevisan (Treviño)
14ba699508 meson: Compile some tests with multiple C standards
We need to ensure that all the expected macros and utilities are working
with all the supported C standards, so just repeat the tests with all
the ones the compiler supports.
2022-11-22 17:23:14 +01:00
Marco Trevisan (Treviño)
641256ea22 gmacros: Prioritize the usage of [[noreturn]] in C++11
We defined G_NO_RETURN as [[noreturn]] in the C++ case, but only after
trying the __attribute__ syntax, so it was never used in GNUC compatible
compilers.

Give it priority instead when supporting a C++11 compiler and onwards.

As per this we need to adapt the code in the places where it was not
properly used (leading to compilation warnings).
2022-11-22 17:23:13 +01:00
Marco Trevisan (Treviño)
372ab7a964 glib: Use G_CXX_STD_VERSION to check how to behave with C++ compilers 2022-11-22 17:23:12 +01:00
Philip Withnall
ebfbd9c56a tests: Remove a manual timeout from desktop-app-info test
It sometimes fails under valgrind, and is pointless: if the test is
wedged, it’s better to catch that with the timeout at the level of
`meson test`, which can be tailored (using `-t`) to the test environment
and wrapper.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2961#note_1600072

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-22 16:11:49 +00:00
Marco Trevisan
3af38a3a1a Merge branch 'coverity-fixes' into 'main'
gthreadpool: Mark an explicit leak as to be ignored

See merge request GNOME/glib!3081
2022-11-22 16:10:01 +00:00
Marco Trevisan
8aef5fc099 Merge branch '2809-str-equal-api-break' into 'main'
gstrfuncs: Fix regression in types accepted by g_str_equal()

Closes #2809

See merge request GNOME/glib!3082
2022-11-22 16:08:58 +00:00
Philip Withnall
3ee8dafb27 gspawn: Fold in safe_fdwalk_with_invalid_fds() helper function
Since it’s now always called the same way after safe_fdwalk() has been
called. This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-22 14:35:12 +00:00
Philip Withnall
59825c92e0 gthreadpool: Mark an explicit leak as to be ignored
This thread is created once during the process’ lifetime and cannot be
destroyed and recreated, as the thread scheduler settings might have
changed since then.

Mark the leak as explicit, mostly for documentation purposes — but it
might quieten some static analysers.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Coverity CID: #1474614
2022-11-22 14:32:25 +00:00
Philip Withnall
b2dd6d9053 giochannel: Fix an invalid comparison
Since commit 2f9e6e977a, `count` has been used here incorrectly: after
`count_unsigned` is initialised, `count` should no longer be used as it
might be unhelpfully negative.

Fix this to correctly use `count_unsigned`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-22 14:06:07 +00:00
Philip Withnall
f0e08e3488 gspawn: Ignore invalid FDs when using safe_fdwalk()
In `safe_closefrom()`, we thought it would be OK to assert that an FD
being closed is valid, when using `safe_fdwalk()`, as it only walks over
known-valid FDs.

However, there is a situation where that might not be true: the program
is being run under valgrind. Valgrind opens some FDs for its own use
which are ≥1024, and it emulates a lowered soft limit on FDs. So if we
were to use `safe_fdwalk_with_invalid_fds()` it would see the lowered
soft limit and not try to close valgrind’s internal FDs.

However, `safe_fdwalk()` looks at `/proc`, which valgrind does not emulate,
so it sees the secret valgrind internal FDs, and then tries to close them.
Valgrind doesn’t like this, prints ‘Warning: invalid file descriptor
1024 in syscall close()’ and returns `EBADF`. That return value
causes `g_close()` to warn about faulty FD refcounting, and that causes
unit test failures.

Fix that by relaxing our assumptions about FD validity: use
the `close_func_with_invalid_fds()` call back for closing FDs
from `safe_fdwalk()`, rather than using `close_func()`. That will
ignore `EBADF` return values.

This should fix valgrind failures like this one:
https://gitlab.gnome.org/GNOME/glib/-/jobs/2389977

Related prior art: https://bugs.freedesktop.org/show_bug.cgi?id=99839

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-22 13:52:01 +00:00
Philip Withnall
bcd364afef gstrfuncs: Fix regression in types accepted by g_str_equal()
The new macro form of `g_str_equal()` had stricter type checking than
the original function form. That would be nice, except it causes new
compiler warnings in third party projects, which counts as an API break
for us, so unfortunately we can’t do it.

Add some tests to prevent regressions on this again.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2809
2022-11-22 13:12:05 +00:00
Marco Trevisan (Treviño)
f9845abe39 gmacros: Define G_CXX_STD_VERSION and check macros
Sadly, in C++ there's not an universal way to get what language standard
is used to compile GLib-based programs, in fact while most compilers
relies on `__cplusplus`, MSVC is defining that, but it does not use it
to expose such information (unless `/Zc:__cplusplus` arg is used).
On the other side, MSVC reports the language standard via _MSVC_LANG [1].

This complication makes us defining some macros in a very complex way
(such as glib_typeof()), because we need to perform many checks just to
understand if a C++ compiler is used and what standard is expecting.

To avoid this, define multiple macros that can be used to figure out
what C++ standard is being used.

[1] https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170
2022-11-21 20:58:54 +01:00
Simon McVittie
054b96fd09 Merge branch '2812-missing-field-initializers' into 'main'
build: Explicitly enable -Wmissing-field-initializers

Closes #2812

See merge request GNOME/glib!3074
2022-11-21 16:07:43 +00:00
Philip Withnall
7d55571c13 build: Explicitly enable -Wmissing-field-initializers
It was previously only enabled (by default) on macOS, which led to
code being committed which triggered warnings, as that CI job is not
always run.

Avoid that risk by always enabling the warning.

The reasoning for using this warning is that explicit initialisation is
clearer than implicit. We also want to support GLib’s public headers
being used in projects which build with
`-Werror=missing-field-initializers`, but can’t easily enable the
warning for our public headers but not our internal code. So enable it
everywhere.

Make it a warning rather than an error, as there’s a risk that system
header changes will trigger it in distro release builds, which would
cause false build failures. By making it a warning, GLib developers can
build with `-Werror` and promote it to an error, while distros can
choose not to.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2812
2022-11-21 10:49:03 +00:00
Мирослав Николић
4f406f3de6 Update Serbian translation
(cherry picked from commit 25df888507)
2022-11-20 14:27:25 +00:00
Marco Trevisan
7ab85b329a Merge branch 'nonnull-in-meson' into 'main'
build: Move -Wnonnull flag to meson.build

See merge request GNOME/glib!3078
2022-11-18 18:17:08 +00:00
Marco Trevisan
92f39d37c5 Merge branch 'scan-build-fixes' into 'main'
A few test improvements for scan-build

See merge request GNOME/glib!3080
2022-11-18 18:12:52 +00:00
Philip Withnall
e5771df643 gvariant: Add an assertion to clarify some tuple logic
This should quell a scan-build error about dereferencing `member_info`
when it’s `NULL` at the end of the function, due to having zero
iterations of the `for` loop.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-18 17:00:42 +00:00
Philip Withnall
146a0a001d gslice: Tag mem_error() as not returning because it aborts
This should quell some scan-build warnings about code breaking after
returning from mem_error() in a weird state.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-18 16:36:47 +00:00
Philip Withnall
0781e12f45 tests: Add additional assertions to gsubprocess test
This should quell a scan-build warning about passing `NULL` to
`strlen()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-18 16:34:06 +00:00
Philip Withnall
a937c8ac5a giochannel: Clarify assertions in g_io_channel_write_chars()
How the assertions handled the case of `buf != NULL && count == -1` and
`buf == NULL && count == -1` were a bit fragile.

In the former case, the `strlen (buf)` was assigned to `count`, which is
signed. If, somehow, `buf` was huge, `count` would end up wrapping
around to a negative number. Avoid that by assigning directly to
`count_unsigned`.

In the latter case, `count_unsigned` would be set to `-1` which would
wrap around. The error would then be caught by the precondition on `buf
!= NULL`, but it seems like that could have been a happy accident rather
than something intentional. Change it to an explicit precondition which
only allows `buf == NULL` iff `count == 0`.

Spotted while reading through static analysis issues, although the
analyser didn’t explicitly flag this up as an issue.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-18 16:18:55 +00:00
Philip Withnall
4ff6ecbeff build: Move -Wnonnull flag to meson.build
It should be enabled in all builds, not just CI builds. Otherwise
developers might miss it locally.

This updates commit f11b96f255.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-18 13:33:20 +00:00
Simon McVittie
c1a4aca743 Merge branch 'coverity-build' into 'main'
gmodule: Fix redeclaration of symbol

See merge request GNOME/glib!3075
2022-11-16 18:41:07 +00:00
Philip Withnall
66bb4ab8cc Merge branch 'misc-docs-and-tests-fixes' into 'main'
Misc docs fixes and test improvements in GAction and GNotificationBackend

See merge request GNOME/glib!3073
2022-11-16 12:16:07 +00:00
Philip Withnall
20266f6089 gmodule: Fix redeclaration of symbol
This should fix the Coverity build, which is currently broken:
https://gitlab.gnome.org/GNOME/glib/-/jobs/2389979
```
../gmodule/gmodule-deprecated.c:8: error: "GLIB_DISABLE_DEPRECATION_WARNINGS" redefined [-Werror]
    8 | #define GLIB_DISABLE_DEPRECATION_WARNINGS
      |
<command-line>: note: this is the location of the previous definition
cc1: all warnings being treated as errors
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 12:02:06 +00:00
Philip Withnall
5f51cc844c gapplicationcommandline: Fix a minor typo in the documentation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
fec865cb0c gapplicationcommandline: Add a missing transfer annotation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
73f445b099 tests: Add some missing error checks to actions test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
b836ed5c13 tests: Stop using GMainLoop in actions test
Instead, iterate the `GMainContext` directly. This allows tests on
asynchronously returned values to be done in the actual test function,
rather than a callback, which should make the tests a little clearer.

This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
19eee4bc41 gtestdbus: Use g_timeout_add_seconds() rather than g_timeout_add()
This makes the code a little easier to understand and allows the kernel
a little bit more leeway in scheduling the callback, which is fine
because we don’t need high accuracy here.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00