31576 Commits

Author SHA1 Message Date
Philip Withnall
9c5409e229
gkeyfile: Update links to various fdo specifications
The old links still work, but we might as well avoid a redirect.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-12 11:31:03 +00:00
Philip Withnall
3e5c454a02
gkeyfilesettingsbackend: Convert docs to gi-docgen linking syntax
Improve formatting while I’m there, and try and ensure all the docs in
these two files matches the
[guidelines](https://developer.gnome.org/documentation/guidelines/devel-docs.html#writing-api-references).

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

Helps: #3250
2025-02-12 11:30:55 +00:00
Marco Trevisan (Treviño)
6160747fe5 girepository/tests: Add tests for the compiler basic operations
Adding some initial test for the compiler behavior and its expected
output.

Also, when using sanitizers we want to be able to test the compiler memory
management.
2025-02-11 21:02:56 +01:00
Marco Trevisan (Treviño)
bf9ea337a2 girepository/tests: Add tests on compiler open/write failures 2025-02-11 21:02:56 +01:00
Marco Trevisan (Treviño)
26890fbb82 ci: Enable introspection for installed tests 2025-02-11 18:51:15 +01:00
Marco Trevisan (Treviño)
00ebf4e1eb tests/lib: Add a new unittest type to simplify launching test programs
We were reusing the same logic everywhere, while we can just reuse an
unique class to base our tests on that avoids having to copy-and-paste
code for no good reason
2025-02-11 18:51:15 +01:00
Marco Trevisan (Treviño)
4bcd99de43 tests: Avoid reusing and installing multiple files the taptestrunner
Add some basic support for having glib-tests-only python libraries that
can be shared across the various projects, so that we don't have to
maintain multiple copies of them.
2025-02-11 18:51:15 +01:00
Marco Trevisan
15edb1b07e Merge branch 'typo' into 'main'
meson: Fix typo in comment about python shebang

See merge request GNOME/glib!4486
2025-02-11 17:09:57 +00:00
Nirbheek Chauhan
8d07ae7ef1 meson: Fix typo in comment about python shebang 2025-02-11 21:37:49 +05:30
Philip Withnall
14a756ae97
gdbusconnection: Add g_dbus_connection_register_object_with_closures2() API
This replaces `g_dbus_connection_register_object_with_closures()`, and
becomes the new binding-friendly version of
`g_dbus_connection_register_object()`.

The problem with `g_dbus_connection_register_object_with_closures()` is
that the `method_call_closure` kept the reference counting semantics of
`GDBusInterfaceMethodCallFunc`, in that the `invocation` argument was
`(transfer full)`, even though it was wrapped in a `GClosure`. This
couldn’t be described in introspection annotations, so the
`GDBusMethodInvocation` was being leaked by bindings. Some bindings
added workarounds to fix the leak at our direction (see
https://gitlab.gnome.org/GNOME/glib/-/issues/2600#note_1385050), which
meant we could no longer change the reference counting behaviour without
breaking those bindings (see #3559).

So let’s start afresh with
`g_dbus_connection_register_object_with_closures2()`, with correctly
defined reference counting semantics (the `GDBusMethodInvocation` is
`(transfer none)`) from the start.

Unfortunately we can’t add a `(rename-to)` annotation to the new API, as
that would effectively be an API break for existing binding code which
uses the old API via that rename.

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

Fixes: #3560
2025-02-11 14:08:05 +00:00
Marco Trevisan
589c8295ea Merge branch 'callable-info-test-leak' into 'main'
tests: Fix a memory leak if a callable-info test is skipped

See merge request GNOME/glib!4483
2025-02-11 13:57:20 +00:00
Philip Withnall
ca760eeeac Merge branch 'windows-fix-shebang' into 'main'
Windows: fix Python path can contain spaces

Closes #3331

See merge request GNOME/glib!4391
2025-02-11 13:42:32 +00:00
Dan Yeaw
160e55575e Windows: fix Python path cannot contain spaces
Move the shebang line from the full Python path of the build
machine to the first Python on the path during runtime. Set
the shebang in the main meson.build file so that it can be
overridden in one place if needed.

Fixes: #3331
2025-02-11 11:57:30 +00:00
Philip Withnall
a127f9b7d2
tests: Fix a memory leak if a callable-info test is skipped
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-11 11:40:29 +00:00
Philip Withnall
8d51095602 Merge branch 'gkeyfile-fix-c-locale-handling' into 'main'
gkeyfile: Fix C locale handling

Closes #3578

See merge request GNOME/glib!4480
2025-02-11 09:31:33 +00:00
Gaël Bonithon
5cc6af2237 gkeyfile: Fix C locale handling
As gettext does:
* if C locale is used to set a value, set the untranslated value, i.e.
  key=value and not key[C]=value;
* if C locale is used to get a value, return the untranslated value,
  i.e. not the value from key[C]=value, if it ever exists, and do not
  consider C as an undefined locale otherwise.

Fixes: #3578
2025-02-11 09:31:33 +00:00
Philip Withnall
ba60ea7aa0 Merge branch 'amolenaar/docs-fixes' into 'main'
docs: Make docs more markdown-ish

See merge request GNOME/glib!4479
2025-02-10 14:40:55 +00:00
Arjan Molenaar
04acc1741b
docs: Make docs more markdown-ish
Fixed some issues that came to light while compiling documentation
for the python bindings.
2025-02-10 10:26:42 +01:00
Philip Withnall
d0b4979327
gsocketlistener: Clarify documentation of add_inet_port()
It wasn’t clear what the fallback behaviour of IPv4 vs IPv6 was, or that
the same port was used for both.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2025-02-07 14:40:49 +00:00
Philip Withnall
36189525f7
gsocketlistener: Clarify documentation of add_any_inet_port()
It wasn’t clear what the fallback behaviour of IPv4 vs IPv6 was, or that
the same port was used for both.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2025-02-07 14:40:35 +00:00
Philip Withnall
64cc9bbc40
gsocketlistener: Fix IPv4 listen() error handling
In add_any_inet_port() for the case where we successfully listen()ed
on IPv6, but failed to listen on IPv4, we would erroneously unref the
IPv6 socket which we just gave away ownership of by adding it to
priv->sockets.

However, given that we have a successful IPv6 socket, we shouldn’t
report it as an error if the IPv4 listen() fails. While this code tries
quite hard to return both sockets, returning only one seems to be the
best we can do in this situation.

This issue was observed in an Android 4.4 ARM emulator. It’s possible
the emulator deferred the bind() on the host until the listen() on the
client.

Based on a patch by Ole André Vadla Ravnås <oleavr@gmail.com>.

https://gitlab.gnome.org/GNOME/glib/issues/1250
2025-02-07 14:38:54 +00:00
Philip Withnall
0234f8e1b1 Merge branch 'ppd-api-rename' into 'main'
gio/powerprofilemonitordbus: Use newer D-Bus API

See merge request GNOME/glib!4478
2025-02-07 08:34:19 +00:00
Marco Trevisan (Treviño)
dba2d618d5 gio/tests/power-profile-monitor*.py: Use upower ppd daemon APIs 2025-02-07 00:55:35 +01:00
Marco Trevisan (Treviño)
71d08b707a gio/tests/power-profile-monitor-*.py: Fix style using black 2025-02-07 00:55:35 +01:00
Marco Trevisan (Treviño)
236abac6fb gio/powerprofilemonitordbus: Use newer DBus API
Since some time the power-profiles-daemon project has been moved under
the upower umbrella and renamed its API to follow that.

While the legacy name is still supported, there are plans to not support
it anymore in future [2]. So let's update GLib code to use the
current main name instead.

[1] https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/merge_requests/148
[2] https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/merge_requests/166
2025-02-07 00:55:32 +01:00
Michael Catanzaro
222546ddd0
gcancellable: remove sketchy source ref/unref
These refcount changes cannot possibly fix any race condition because
there is no guarantee that the g_source_ref() will be called in this
thread before any g_source_unref() that might happen on another thread.
We would have to take the ref sooner for it to be effective.

It's also not clear why we take a ref at all, since the source is
already being disposed and there's no explanation of why we should
resurrect it here. It can't be finialized until the call to dispose is
finished, so it's unclear what we are guarding against.

I'm not sure about the correctness of this code and make no promises
that there are no bugs here, but I think this change shouldn't make
anything worse.
2025-02-06 12:14:34 -06:00
Philip Withnall
d4245f70d4
tests: Add a basic test for GScanner’s int_2_float configuration
I can see why use of `GScanner` is discouraged. Eww.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4387/diffs#note_2269329

Choose a large enough int to cause problems if `long` storage isn’t used
throughout the parse chain.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-06 13:00:13 +00:00
Philip Withnall
8e39ad2660
tests: Add a basic test for g_scanner_sync_file_offset()
See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4387#note_2269328

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-06 13:00:08 +00:00
Philip Withnall
020e58bac5
tests: Add basic tests for comments and FD input in GScanner
See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4387#note_2269327

This is nowhere near a comprehensive test suite for `GScanner`, but it
at least means we have more of a basis for that, and a regression test
for the above change.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-06 13:00:04 +00:00
Philip Withnall
00f54b1bcc Merge branch 'fix-docs-links' into 'main'
docs: Fix invalid references and broken links

See merge request GNOME/glib!4475
2025-02-06 12:38:51 +00:00
Philip Withnall
84e26432c8
tests: Add a test for command line option parsing errors
See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4387#note_2269326

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-06 12:35:41 +00:00
Philip Withnall
7dca1fb094
tests: Add a basic test for g_log_writer_journald()
While we can’t test that its functionality actually does anything, we
can call it and execute its code and see if it crashes.

This adds basic code coverage for it.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4387#note_2269325

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-06 12:27:26 +00:00
Philip Withnall
84bd676519
tests: Add a missing test for post-normalisation lowercasing in IDN
See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4387#note_2269324

This adds a test to increase the code coverage of `nameprep()` in
`ghostutils.c`. It was previously missing coverage of the second
`tolower()` operation. The new test triggers this by using a Unicode
codepoint which cannot be converted to lowercase itself, but which
normalises (NFKC) to uppercase characters which can — a Unicode Roman
numeral.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-06 12:27:22 +00:00
Philip Withnall
72ca779e36
tests: Use g_assert_*() rather than g_assert() in option-context tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-06 12:27:17 +00:00
Philip Withnall
a6c36498ed
ghostutils: Limit punycode decoding output length
It uses a `GArray` to build up the output, and the size of that is
limited to a `guint`, so add an assertion to make sure the code never
requests anything bigger.

Fixes a `-Wshorten-64-to-32` warning.

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

Helps: #3527
2025-02-06 12:27:11 +00:00
Philip Withnall
e35aa61a55
ghostutils: Clarify string ownership transfers
Rename the `tmp` variable to `name_owned` to make its purpose clearer,
and more consistently assign to both it and `name` and `len` (which is
the length of `name`) every time any of them are modified.

This should make the function `const`-correct without the need for
casts, and introduce no functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-06 12:27:03 +00:00
Philip Withnall
91b491241e
ghostutils: Fix string length handling to use gssize
Rather than `gint`, which can overflow for long strings, although such
strings would probably have hit hostname length limits already.

This fixes a `-Wshorten-64-to-32` warning.

I looked at changing from `gssize` to `size_t` and handling the `len <
0` case with an explicit early call to `strlen()`, but it didn’t make
things simpler, as the code in `nameprep()` keeps changing the length of
the string as it processes it.

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

Helps: #3527
2025-02-06 12:26:59 +00:00
Philip Withnall
a5682aff2e
goption: Fix string length handling to use size_t type
When parsing command line options, use `size_t` to hold string lengths.
This introduces no functional changes (any strings long enough to fit in
`size_t` but not in `int` will probably hit command line length limits),
but it does fix a `-Wshorten-64-to-32` warning.

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

Helps: #3527
2025-02-06 12:26:54 +00:00
Philip Withnall
4d49fc8222
goption: Move a variable declaration to the scopes where it’s used
This introduces no functional changes, it just splits the declaration of
`j` into three smaller-scoped declarations of the same type. This will
make the following commit clearer.

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

Helps: #3527
2025-02-06 12:26:50 +00:00
Philip Withnall
664aca14a5
goption: Add explicit int cast in integer parsing code
The code uses `strtol()` to parse an integer from a string, then
correctly verifies its range, then it did an implicit cast to `int` to
return the parsed integer. This causes a spurious `-Wshorten-64-to-32`
warning, so add an explicit cast to make the code’s intention clear.

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

Helps: #3527
2025-02-06 12:26:45 +00:00
Philip Withnall
63af851f15
goption: Fix string length storage to use size_t rather than int
This moves all the string length handling in this part of `goption.c` to
use `size_t`. However, we need to assert that the string length is
at most `G_MAXINT` later on, as the length is passed to `printf()` to
add indentation, and it only accepts `int` for that kind of placeholder.

This introduces no functional changes, but does fix some
`-Wshorten-64-to-32` warnings.

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

Helps: #3527
2025-02-06 12:26:41 +00:00
Philip Withnall
30c47b059c
glib-init: Fix type used for string length storage
This fixes a `-Wshorten-64-to-32` warning.

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

Helps: #3527
2025-02-06 12:26:36 +00:00
Philip Withnall
8c37608c0d
gpattern: Fix use of narrow types to contain string offsets
When parsing the pattern in `g_pattern_spec_new()`, the offsets of
wildcards and jokers were stored in a `gint`. This could overflow with
exceptionally long patterns.

Split the sign out into a separate boolean for `hw_pos` and `hj_pos`
(it’s not necessary for `tw_pos` or `tj_pos` because their sign was
never queried), and use `size_t` to correctly store string offsets.

Fixes a `-Wshorten-64-to-32` warning.

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

Helps: #3527
2025-02-06 12:26:29 +00:00
Philip Withnall
66f4a52bd6
grand: Add an explicit cast to silence a -Wshorten-64-to-32 warning
The seed is explicitly a `guint32`, so an implicit cast was already
happening. We don’t actually care if there’s a loss of precision here,
as it’s a pseudo-random seed value rather than an ordinal number, so add
an explicit cast to silence the warning.

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

Helps: #3527
2025-02-06 12:26:22 +00:00
Philip Withnall
b8e68db45b
grand: Fix return type for fread() call
This fixes a `-Wshorten-64-to-32` warning, but there’s no underlying bug
here, as the maximum requested read size is 4 bytes anyway.

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

Helps: #3527
2025-02-06 12:26:14 +00:00
Philip Withnall
49d8185d03
gscanner: Fix -Wshorten-64-to-32 warning when reading an integer token
There’s already a documented explicit cast here, so let’s add the
explicit cast in C to match that. Fixes a `-Wshorten-64-to-32` warning.

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

Helps: #3527
2025-02-06 12:26:00 +00:00
Mavroudis Chatzilazaridis
cb1502ed66 docs: Fix invalid references and broken links
This commit fixes quite a few broken links and references, minor typos,
and improves wording in some sections.
2025-02-05 22:28:26 +02:00
Michael Catanzaro
f5eb3fd716 Merge branch 'sysprof-leak' into 'main'
glib.supp: Ignore once-per-thread leak from SysprofCollector

See merge request GNOME/glib!4471
2025-02-05 17:33:40 +00:00
Philip Withnall
aea78c9ac7
docs: Tweak release instructions around signing
Suggest to sign the release commit itself (to keep us in sync with the
Handbook; https://handbook.gnome.org/maintainers/making-a-release.html);
and allow `git tag -s` if `git evtag` is not available (also as per the
Handbook).

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

Fixes: #3424
2025-02-04 17:02:04 +00:00
Philip Withnall
7fffe59037 Merge branch 'wip/pwithnall/soft-c11-dependency' into 'main'
build: Add a soft dependency on C11

See merge request GNOME/glib!4473
2025-02-04 16:35:33 +00:00