Commit Graph

7227 Commits

Author SHA1 Message Date
Philip Withnall
8e185e12c9 tests: Fix a flaky wait in converter-stream
Rather than waiting for a fixed period of time, poll in a loop until the
condition the test is expecting is true.

A better solution would be to use a `GSource` and wait until that’s
dispatched. But doing so might affect the behaviour of the
`GInputStream` under test, so busy-wait instead.

Fixes this CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/1630758

```
(some socket debug output)
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1037:test_converter_pollable: assertion failed (res == -1): (1 == -1)
```

I could not reproduce the failure remotely with a few hundred
invocations of the test, so it might only present itself on BSD, which
presumably has different socket timing behaviour from Linux.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-22 13:22:25 +00:00
Philip Withnall
40037ebbfc tests: Use g_assert_*() rather than g_assert() in converter-stream.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-22 13:20:17 +00:00
Alexander Kanavin
e161c62292 gio/tests/codegen.py: bump timeout to 100 seconds
This may be necessary on overloaded CI systems.
2021-11-18 14:07:11 +01:00
Frederic Martinsons
296a8c6522 Sort output of gsettings command-line tool
Closes #1781

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-11-18 08:59:55 +01:00
Philip Withnall
b09ccc4635 Merge branch 'fix_all_warnings' into 'main'
Fix final warnings in Windows code

See merge request GNOME/glib!2323
2021-11-17 15:15:46 +00:00
Emmanuel Fleury
22037bfab2 Fix set but unused parameter warning in gio/tests/gio-du.c
gio/tests/gio-du.c: In function 'main':
gio/tests/gio-du.c:74:11: error: parameter 'argc' set but not used
   74 | main (int argc, char **argv)
      |       ~~~~^~~~
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
dea0ec3df6 Fix signedness warning in gio/ginputstream.c
gio/ginputstream.c: In function 'g_input_stream_real_skip':
gio/ginputstream.c:433:31: error: comparison of integer expressions of different signedness: 'goffset' {aka 'long long int'} and 'long long unsigned int'
  433 |               (start + count) > (guint64) end)
      |                               ^
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
264055f3c0 Fix signedness warnings in gio/gwin32appinfo.c
gio/gwin32appinfo.c: In function 'uwp_package_cb':
gio/gwin32appinfo.c:3383:17: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
   for (i = 0; i < supported_extgroups->len; i++)
                 ^
gio/gwin32appinfo.c:3389:29: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_ext = 0; i_ext < grp->extensions->len; i_ext++)
                             ^
gio/gwin32appinfo.c:3430:35: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
           for (i_verb = 0; i_verb < grp->verbs->len; i_verb++)
                                   ^
gio/gwin32appinfo.c:3463:33: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_hverb = 0; i_hverb < ext->verbs->len; i_hverb++)
                                 ^
gio/gwin32appinfo.c:3478:17: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
   for (i = 0; i < supported_protocols->len; i++)
                 ^
gio/gwin32appinfo.c:3541:33: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_hverb = 0; i_hverb < url->verbs->len; i_hverb++)
                                 ^
gio/gwin32appinfo.c: In function 'g_win32_app_info_launch_internal':
gio/gwin32appinfo.c:4799:37: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
           for (p_index = 0; p_index <= g_strv_length (envp); p_index++)
                                     ^~
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
f9b4a557b1 Fix signedness warning in gio/gwin32packageparser.c
gio/gwin32packageparser.c: In function 'WIN32_FROM_HRESULT':
gio/gwin32packageparser.c:99:30: warning: comparison of integer expressions of different signedness: 'long unsigned int' and 'long int'
   if ((hresult & 0xFFFF0000) == MAKE_HRESULT (SEVERITY_ERROR, FACILITY_WIN32, 0) ||
                              ^~
2021-11-17 14:40:28 +01:00
Hristo Venev
9bd4730008 gsubprocess: Add G_SUBPROCESS_FLAGS_SEARCH_PATH_FROM_ENVP 2021-11-17 12:27:46 +00:00
Philip Withnall
511c5f5bf0 tests: Wait for gdbus-testserver to die when killing it
This was previously done (by commit 63038d1e4c) in one of the cases
where `kill_test_service()` was called — but not the other.

This meant that one instance of `gdbus-testserver` could still be
around when (as it happens, due to the order of the tests) the
`/gdbus/proxy/no-match-rule` test was run. It would start a second
instance of `gdbus-testserver`, which would exit early due to the test
name still being owned on the bus. The first (killed) instance of
`gdbus-testserver` would then exit, leaving no test servers running, and
hence the new test would fail.

This was being seen as frequent CI failures, particularly on FreeBSD
(must have slightly different timing for process signalling and
termination from Linux).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 22:47:15 +00:00
Michael Catanzaro
d1e9e0c094 gsocketclient: deprecate tls-validation-flags property
It doesn't work as expected, and you shouldn't be trying to use it
anyway.
2021-11-16 15:21:22 +00:00
Michael Catanzaro
38de97c148 gtlsclientconnection: deprecate validation-flags property
It doesn't work as expected, and you shouldn't be trying to use it
anyway.
2021-11-16 15:21:21 +00:00
Michael Catanzaro
780af9cff3 Document potential footgun with GTlsCertificateFlags
Once upon a time, we tried to return all possible certificate errors,
but it never actually worked reliably and nowadays we have given up.
This needs to be documented because a reasonable developer would not
expect it.

Because mistakes could be security-critical, I decided to copy the same
warning in several different places rather than relying only on
cross-referencese.
2021-11-16 15:21:21 +00:00
Sebastian Dröge
6a7187cae4 Merge branch 'actions-test-fix' into 'main'
tests: Drop arbitrary and flaky waits from actions tests

See merge request GNOME/glib!2336
2021-11-16 14:37:24 +00:00
Maurice
366597a10d Fix GSettings dict error macOS 2021-11-16 14:21:00 +00:00
Philip Withnall
4eafbaba94 tests: Fix two small leaks in the actions test
These are known leaks, as they were being done in tests which were
checking precondition failures.

However, since we know what happens when the failures occur, we can
still free the input data reliably, so do that.

This improves the valgrind output for `actions` to show zero definite
leaks.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 14:03:36 +00:00
Philip Withnall
c8fa295f6a tests: Drop arbitrary and flaky waits from actions tests
The `actions` test previously waited an arbitrary 100ms for various
D-Bus messages to be sent/received, before checking the results of those
messages.

Normally, this would work, but on heavily loaded CI systems, it would
sometimes fail. For example,
https://gitlab.gnome.org/GNOME/glib/-/jobs/1611701.

Fix that by waiting for the condition being checked to evaluate to true,
rather than waiting an arbitrary period of time. On faster machines,
this will speed the tests up too.

Assume that the global default `GMainContext` is in use, so a
`GMainContext*` pointer doesn’t have to be passed around.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 14:01:24 +00:00
Emmanuel Fleury
9e3a08b222 Fix signedness warning in gio/gcontenttype-win32.c
gio/gcontenttype-win32.c: In function 'get_registry_classes_key':
gio/gcontenttype-win32.c:66:78: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int'
               if (ExpandEnvironmentStringsW (wc_temp, wc_temp_expanded, len) == len)
                                                                              ^~
2021-11-12 14:58:52 +01:00
Lubomir Rintel
a107a328e4 gdbusproxy: Add G_DBUS_PROXY_FLAGS_NO_MATCH_RULE flag
D-Bus has an upper limit on number of Match rules and it's rather easy to hit
with a big number of proxies with signal subscriptions. This happens with
NetworkManager with hundreds of devices or connection settings. By passing
G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE to g_dbus_connection_signal_subscribe(), the
user can call AddMatch with a less granular match instead of a match per every
proxy.

Tests subsequently added by Philip Withnall.

Fixes: #1109
2021-11-04 11:44:18 +00:00
Michael Catanzaro
caf777984b Merge branch '2426-delayed-settings-null-handling' into 'main'
gdelayedsettingsbackend: Fix applying after calling g_settings_reset()

Closes #2426

See merge request GNOME/glib!2161
2021-11-03 18:03:21 +00:00
Philip Withnall
7be79cb840 Merge branch '2310-xdgmime-leaks' into 'main'
gcontenttype: Ignore intentional one-time leaks from xdgmime

Closes #2310

See merge request GNOME/glib!2268
2021-11-03 15:42:20 +00:00
Philip Withnall
fd080d8564 Merge branch 'list-model-doc-fixes' into 'main'
docs: Fix the GListModel description

See merge request GNOME/glib!2319
2021-11-03 11:46:28 +00:00
Philip Withnall
1161bd8078 Merge branch 'drop-old-xdgmime-change' into 'main'
Revert "Don't compile some unused functions in gio/xdgmime/"

See merge request GNOME/glib!2277
2021-11-02 09:28:22 +00:00
Emmanuele Bassi
192b3e6c2d docs: Fix the GListModel description
- Isolate the first meaningful paragraph, for gi-docgen's summary
- Describe get_object() as a binding API
- Fix reference to get_item() inside get_item_type()
2021-11-01 18:41:50 +00:00
Philip Withnall
726c44c348 Merge branch '2400-dbus-race' into 'main'
gdbusconnection: Fix race between method calls and object unregistration

Closes #2400

See merge request GNOME/glib!2265
2021-11-01 18:37:17 +00:00
Pablo Correa Gómez
14c5589ed6
gdbusaddress: setuid error message references AT_SECURE
g_check_setuid does more than setuid checks when using AT_SECURE.
Make sure that it is referenced in the error message to help
users debug in case or errors

Closes #2518
2021-11-01 15:54:55 +01:00
Philip Withnall
3dcae415a4 Revert "Don't compile some unused functions in gio/xdgmime/"
This reverts commit 14e46ca288.

Diverging from upstream xdgmime is a maintenance burden, and this
isn’t really much additional code to compile. It should be dropped by
the linker since it’s unused.

See https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/15.
2021-11-01 12:06:26 +00:00
Philip Withnall
e4bb09d8ec Merge branch 'fix-win32-app-info-registry-key-assert' into 'main'
GWin32AppInfo: Do not assert about successful open'ing of registry keys

See merge request GNOME/glib!2260
2021-11-01 10:41:31 +00:00
Philip Withnall
34ce204fd7 tests: Add D-Bus object/subtree unregistration tests
These tests cover the fixes from the previous two commits.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
117b748e44 gdbusconnection: Fix race between subtree method call and unregistration
Fix another variant of the previous commit, this time specific to the
idle callback of a method call on a subtree object, racing with
unregistration of that subtree.

In this case, the `process_subtree_vtable_message_in_idle_cb()` idle
callback already has a pointer to the right `ExportedSubtree` struct,
but again doesn’t have a strong reference to it.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
50fbf05d61 gdbusconnection: Fix race between method calls and object unregistration
If `g_dbus_connection_unregister_object()` (or `unregister_subtree()`)
was called from one thread, while an idle callback for a method call (or
a property get or set) was being invoked in another, it was possible for
the two to race after the idle callback had checked that the
object/subtree was registered, but before it had finished dereferencing
all the data related to that object/subtree.

Unregistering the object/subtree would immediately free the data,
leading the idle callback to cause a use-after-free error.

Fix that by giving the idle callback a strong reference to the data from
inside the locked section where it checks whether the object/subtree is
still registered.

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

Fixes: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
c8c2ed4af5 gdbusconnection: Make ExportedInterface/ExportedSubtree refcounted
This is needed for an upcoming change which decouples their lifecycle
from their presence in the `map_id_to_ei` and `map_id_to_es` hash
tables.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
a497fdf302 gdbusconnection: Add some ownership annotations
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-28 14:53:48 +01:00
Philip Withnall
310f2c1632 gdbusconnection: Move ExportedSubtree definition
Move it further up the file, but make no changes to it. This will help
with a subsequent commit.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
44cbba5d78 gsettings: Drop internal delayed member
This introduces no functional changes; it only simplifies the code.

Instead of maintaining a separate pointer to the backend iff it’s a
`GDelayedSettingsBackend`, just test the `backend` pointer’s type.

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

Helps: #2426
2021-10-26 14:29:31 +01:00
Philip Withnall
0101ccba16 gsettings: Clarify that g_settings_get_child() inherits delay-apply
Previously, the delay-apply status of the parent `GSettings` object
would be partially inherited: `settings->priv->backend` in the child
`GSettings` object would point to a `GDelayedSettingsBackend`, but
`settings->priv->delayed` would be `NULL`.

The expectation from https://bugzilla.gnome.org/show_bug.cgi?id=720891
was that `get_child()` would fully inherit delay-apply status.

So, ensure that `settings->priv->delayed` is correctly set to point to
the delayed backend when constructing any `GSettings`. Update the tests
to work again (presumably the inverted test was an oversight in the
original changes).

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

Fixes: #2426
2021-10-26 14:25:51 +01:00
Philip Withnall
3db22ab8db gsettings: Improve documentation formatting slightly
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-26 14:02:54 +01:00
Philip Withnall
05523b7503 tests: Use a helper macro to drop redundant code in gsettings test
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-26 13:38:22 +01:00
Philip Withnall
8b443c3556 gdelayedsettingsbackend: Fix applying after calling g_settings_reset()
`g_settings_reset()` changes the value of the setting to `NULL`;
`add_to_tree()` was not handling that correctly.

Add a unit test.

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

Fixes: #2426
2021-10-26 13:38:22 +01:00
Emmanuel Fleury
8444dc5695 Fix cast from pointer to integer of different size warning in gio/gwin32appinfo.c 2021-10-26 11:48:48 +00:00
Marc-André Lureau
b26855579c gio: fix GFile doc indentation and nullable annotations
Add missing (nullable), and use 2-space indentation to avoid markdown
pre-formatted blocks when unwanted.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Marc-André Lureau
3a6e8bc887 gio: check the given child name is not an absolute path
As this would have undesirable consequence.

Quoting Philip Withnall:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2305#note_1294729:

  The documentation never said anything about accepting absolute paths,
  so any code which is relying on that is relying on undocumented
  behaviour. We’re allowed to change that.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Marc-André Lureau
1df7c2ea80 gio: document g_file_get_relative_path() with absolute path
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Philip Withnall
464470dd8f Merge branch '2507-file-enumerator-docs' into 'main'
gfileenumerator: Warn if name is not available for get_child()

Closes #2507

See merge request GNOME/glib!2307
2021-10-21 11:58:32 +00:00
Philip Withnall
b6424b5ce1 gfileenumerator: Warn if name is not available for get_child()
`standard::name` must be available for `g_file_enumerator_get_child()`
to work. Emit a critical warning and return if it’s not. This is similar
to the existing behaviour in `g_file_enumerator_iterate()`.

Improve the documentation to mention this.

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

Fixes: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
e508a0a8df gfileenumerator: Upgrade existing warning to critical warning
The code cannot function correctly if the `standard::name` attribute is
not present, so upgrade the existing warning to a critical warning and
return if it fails in `g_file_enumerator_iterate()`.

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

Helps: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
0630272388 gfileenumerator: Add missing precondition to get_child()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
9b1b04587c gunixmounts: Drop references to pamconsole mount option
It was Red Hat specific when it was introduced in 2004, was never
supported by mount(8) upstream, and was removed entirely in 2008.

It’s confusing for GLib to keep references to it around.

Thanks to Karel Zak for digging up the history of it:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2298#note_1294519

And thanks to Xidorn Quan for looking into it in the first place (see
!2298).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-21 12:22:54 +01:00
Emmanuel Fleury
db5a9d8397 Fix signedness warning in gio/gsocket.c
gio/gsocket.c: In function 'g_socket_get_available_bytes':
gio/gsocket.c:3141:17: warning: comparison of integer expressions of different signedness: 'u_long' {aka 'long unsigned int'} and 'int'
       if (avail == -1)
                 ^~
gio/gsocket.c: In function 'g_socket_send_messages_with_timeout':
gio/gsocket.c:5283:19: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
     for (i = 0; i < num_messages; ++i)
                   ^
gio/gsocket.c:5308:76: warning: operand of ?: changes signedness from 'int' to 'gsize' {aka 'long long unsigned int'} due to unsignedness of other operand
         result = pollable_result == G_POLLABLE_RETURN_OK ? bytes_written : -1;
                                                                            ^~
2021-10-20 17:09:50 +02:00