Commit Graph

25524 Commits

Author SHA1 Message Date
Philip Withnall
164d3759fb Merge branch 'mcatanzaro/#2597' into 'main'
Avoid crashing when GProxyResolver returns weird results, and related fixes

Closes #2597

See merge request GNOME/glib!2742
2022-06-28 10:33:33 +00:00
Marco Trevisan
113d7263c6 Merge branch 'wip/pwithnall/more-macos-test-fixes' into 'main'
tests: Fix incorrect basename comparison in gsubprocess test

See merge request GNOME/glib!2785
2022-06-28 01:26:31 +00:00
Michael Catanzaro
8e29865112 gproxyresolver: add asserts to ensure error is set
This will catch buggy implementations of GProxyResolver before they are
able to return bogus results to higher level code. In particular, if
g_proxy_resolver_lookup() returns NULL, it'd better set an error to
explain why.
2022-06-27 15:10:25 -05:00
Michael Catanzaro
1738fad172 proxyaddressenumerator: set error parameter more thoughtfully
It doesn't make sense for a proxy resolver to return NULL without an
error on the first call. Whereas a DNS resolver would do this to
indicate that a query completed successfully but found no results, a
proxy resolver should return "direct://" instead. Therefore, if we are
going to return NULL, we ought to have an error as well. Let's make sure
this actually happens by adding some fallback errors just in case
GProxyResolver feeds us weird results.

Additionally, we should not return any errors except
G_IO_ERROR_CANCELLED after the very first iteration. This is an API
contract of GSocketAddressEnumerator. Let's add some checks to ensure
this.

Note that we have inadequate test coverage for GProxyAddressEnumerator.
It's tested here only via GSocketClient. We could do a bit better by
testing it directly as well. For example, I've added tests to see what
happens when GProxyResolver returns both a valid and an invalid URI, but
it's not so interesting here because GSocketClient always uses the valid
result and ignores the error from GProxyAddressEnumerator.

Fixes #2597
2022-06-27 15:10:05 -05:00
Michael Catanzaro
6f83f45db4 gsimpleproxyresolver: ensure default proxy is valid
It should be either a valid URI, or NULL. Passing empty strings or other
invalid URIs is no bueno.
2022-06-27 14:23:51 -05:00
Michael Catanzaro
8a1f087a31 gsimpleproxyresolver: default_proxy should be consistently nullable
Currently it's nullable in g_simple_proxy_resolver_new(), but not in
g_simple_proxy_resolver_set_default_proxy() nor the property. Fix these.
2022-06-27 14:23:51 -05:00
Michael Catanzaro
4667f5980a proxy-test: fix check for simple:// URI scheme
This has no practical impact, since it's only a test, and none of the
test code would have hit this bug, but the GTestProxyResolver's check to
see if the URI scheme is simple:// currently only compares the first
four bytes of the string, so it's actually only checking for the "simp"
and would match anything else after that, e.g. "simpleton://". This is
surely not intended.
2022-06-27 14:23:51 -05:00
Philip Withnall
087272777b tests: Fix incorrect basename comparison in gsubprocess test
This was causing intermittent failures on macOS, depending on whether
the tmpdir ended with a `/` or `/some-dir`. `g_strrstr()` is not the
right function to use to extract a basename from a path, for this
reason.

When it failed, the macOS test was failing with:
```
ok 16 /gsubprocess/env
Bail out! GLib-GIO:ERROR:../gio/tests/gsubprocess.c:1507:test_cwd: assertion failed (basename == tmp_lineend_basename): ("/T\n" == "/\n")
```

The test now passes reliably, which means that it can be removed from
the list of expected failures on macOS.

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

Helps: #1392
2022-06-27 15:02:55 +01:00
Philip Withnall
6d381c9668 Merge branch 'getfsent_lock' into 'main'
Add lock in _g_get_unix_mount_points() around *fsent() functions

See merge request GNOME/glib!1717
2022-06-27 11:20:49 +00:00
Philip Withnall
3c47fa6e20 Merge branch 'getfsent_lock2' into 'main'
_g_get_unix_mount_points(): reduce syscalls inside loop

See merge request GNOME/glib!2783
2022-06-27 11:14:01 +00:00
Philip Withnall
eec8171dab Merge branch 'wip/smcv/more-figure-spaces' into 'main'
gdatetime test: Consistently expect %k to generate a figure space

See merge request GNOME/glib!2773
2022-06-27 11:09:26 +00:00
Simon McVittie
6a599e0349 gdatetime test: Consistently expect %k to generate a figure space
This part of test_non_utf8_printf() was missed while converting other
test expectations to look for a figure space, probably because it is
only run if a legacy ja_JP.eucjp locale exists. Debian generates a fairly
comprehensive set of locales (including some that are non-UTF-8) while
running GLib's installed-tests, so this was caught by CI.

Fixes: 7074122 "gdatetime: Pad numbers with numeric space"
Signed-off-by: Simon McVittie <smcv@debian.org>
2022-06-27 09:29:35 +01:00
Michael Catanzaro
6e81c21a8b Merge branch 'wip/smcv/revert-fa8c7c0d' into 'main'
Revert "gobject: Use g_datalist_id_remove_multiple"

See merge request GNOME/glib!2784
2022-06-26 17:16:51 +00:00
Simon McVittie
d4043eced5 Revert "gobject: Use g_datalist_id_remove_multiple"
This reverts commit fa8c7c0 "gobject: Use g_datalist_id_remove_multiple"
(or more specifically the parts of it that were not already reverted
in 01ac1d9 "gobject: Fix crash when disposing a GtkAccelGroup".

Workaround for https://gitlab.gnome.org/GNOME/glib/-/issues/2676

Bug: https://gitlab.gnome.org/GNOME/glib/-/issues/2676
2022-06-26 18:00:52 +01:00
Aleksandr Melman
f3838e517b Update Russian translation 2022-06-25 18:40:19 +00:00
Rozhuk Ivan
f43cf34151 [PATCH] Add lock in _g_get_unix_mount_points() around *fsent() functions 2022-06-25 19:22:06 +03:00
Rozhuk Ivan
02d0d6497b [PATCH] _g_get_unix_mount_points(): reduce syscalls inside loop 2022-06-25 19:01:30 +03:00
Simon McVittie
99a7c6351c Merge branch 'wip/pwithnall/more-macos-fixes' into 'main'
tests: Fix macOS failures in the file tests

See merge request GNOME/glib!2779
2022-06-25 10:23:49 +00:00
Philip Withnall
059a5fd4da tests: Skip various default handler tests on macOS
They are not currently supported by `gosxappinfo.m`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-24 12:43:18 +01:00
Philip Withnall
dbdc9ca995 gosxappinfo: Correctly return an error from create_from_commandline()
Creating a `GAppInfo` from a commandline isn’t currently supported on
macOS, but the implementation was incorrectly returning `NULL` without
setting the `GError`.

This was being caught by the new tests in `gio/tests/file.c`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-24 12:27:45 +01:00
Philip Withnall
a98bd895d5 tests: Fix a path comparison in the file tests
On macOS the comparison was failing as one of the paths had a trailing
slash while the other didn’t.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-24 12:27:45 +01:00
Yuri Chornoivan
468e096983 Update Ukrainian translation 2022-06-24 06:36:19 +00:00
Hugo Carvalho
44bb5c26fc Update Portuguese translation 2022-06-23 21:39:02 +00:00
Philip Withnall
ac898b8e67 Merge branch 'fix-macos-again' into 'main'
tests: Fix type mismatches in new atomic tests when compiling with clang

See merge request GNOME/glib!2774
2022-06-23 18:44:13 +00:00
Philip Withnall
b5231ed003 Merge branch 'gthread-initial-cleanups' into 'main'
gthread: Some code cleanups and fixes

See merge request GNOME/glib!2775
2022-06-23 17:07:09 +00:00
Philip Withnall
191923ce61 Merge branch 'wip/smcv/none-flags' into 'main'
Add a NONE or DEFAULT member to most flags-sets

See merge request GNOME/glib!2576
2022-06-23 16:09:38 +00:00
Marco Trevisan (Treviño)
8d98617297 gthread-posix: Use named states to manage the mutex states
We used to use raw numbers to control the mutex state, we can use a
nicer enum to avoid dealing with pure numbers.
2022-06-23 17:50:12 +02:00
Marco Trevisan (Treviño)
15d2053122 glib/tests/autoptr: Also ensure that GRecMutexLocker can re-lock a mutex
It's native in the actual GRecMutex, but better to check that again.
2022-06-23 17:48:44 +02:00
Marco Trevisan (Treviño)
e2d2db6433 glib/tests/autoptr: Release the acquired locks on GRecMutex 2022-06-23 17:48:44 +02:00
Marco Trevisan (Treviño)
9dffecf5f5 gthread: Fix Since tag typo in documentation for some methods 2022-06-23 17:45:04 +02:00
Philip Withnall
35c4b640bb tests: Fix type mismatches in new atomic tests when compiling with clang
Clang seems to apply more rigorous type checks across the different
arguments to the atomic builtins. Fix various
`-Wincompatible-pointer-types`, `-Wpointer-sign` and `-Wint-conversion`
warnings.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-23 15:56:07 +01:00
Philip Withnall
d198edf9cd Merge branch 'leaks' into 'main'
gobject/tests/performance: fix leaks

See merge request GNOME/glib!2772
2022-06-23 13:47:33 +00:00
Philip Withnall
e5ccbe09da Merge branch 'atomic-exchange-pre-value' into 'main'
gatomic: Add Compare and Exchange functions that returns the previous value

See merge request GNOME/glib!2766
2022-06-23 13:19:05 +00:00
Marc-André Lureau
a5d551e2be gobject/tests/performance: fix leaks
Easily spotted by ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-06-23 17:18:21 +04:00
Philip Withnall
5655af6ada Merge branch 'more-async-gfile' into 'main'
gfile (and GAppInfo): Add some missing async APIs and ensure async calls always use them

See merge request GNOME/glib!2717
2022-06-23 11:49:55 +00:00
Philip Withnall
6529be2950 Merge branch 'ericLemanissier-main-patch-01384' into 'main'
use gvdb as a subproject

See merge request GNOME/glib!2771
2022-06-23 10:00:34 +00:00
Philip Withnall
ea7be5b249 Merge branch 'wip/smcv/atomic-pointer-exchange-docs' into 'main'
Correct documentation of g_atomic_pointer_exchange

See merge request GNOME/glib!2770
2022-06-23 09:58:23 +00:00
Simon McVittie
879b9cd669 gregex: Add G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:39 +01:00
Simon McVittie
0d4e401ede gmarkup: Add G_MARKUP_PARSE_FLAGS_NONE
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:27 +01:00
Simon McVittie
cef780e9ef giochannel: Add G_IO_FLAG_NONE
This makes the state where no flags are set a bit more self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:22 +01:00
Simon McVittie
cc528f6c2e giomodule test: Don't pass a magic number to g_test_trap_subprocess()
This worked, but seems like bad style.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:19 +01:00
Simon McVittie
de8672fe0b gtestutils: Add G_TEST_SUBPROCESS_DEFAULT, G_TEST_TRAP_DEFAULT
This makes calls to test subprocesses with default behaviour more
self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:13 +01:00
Simon McVittie
f59e02a143 gioenums: Add G_TLS_CERTIFICATE_FLAGS_NONE
This makes the absence of flags (in other words, a valid certificate)
more self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:05 +01:00
Simon McVittie
7045260c22 gsignal: Add G_CONNECT_DEFAULT
This makes calls to g_signal_connect_data() and g_signal_connect_object()
with default flags more self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:46:45 +01:00
Simon McVittie
5e164c6615 gtype: Add G_TYPE_FLAG_NONE
This makes code that sets no flags a bit more self-documenting:
using G_TYPE_FLAG_NONE makes it clearer that no special behaviour is
required than literal 0, and clearer that there is no weird casting
between types than (GTypeFlags) 0.

GTypeFlags and GTypeFundamentalFlags occupy the same namespace and the
same bitfield, so I intentionally haven't added
G_TYPE_FUNDAMENTAL_FLAGS_NONE.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:45:31 +01:00
ericLemanissier
f2ea67ae44 use gvdb as a subproject
this fixes the build when using --wrap-mode=nofallback
fix proposed by @eschwartz
2022-06-23 08:26:21 +00:00
Simon McVittie
69f7b03c38 Correct documentation of g_atomic_pointer_exchange
The references to gint and guint were copy/pasted from
g_atomic_int_exchange(), but what we want here is a gpointer, gintptr
or guintptr like the rest of the g_atomic_pointer_ family.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 09:20:35 +01:00
Marco Trevisan (Treviño)
922bc1d995 build: Use _GLIB prefix for GCC features we detected at build time
We used a _GCC prefix that is not our namesapce, so even if such value
is not provided by the compiler, let's just use a better name.
2022-06-22 23:01:33 +02:00
Marco Trevisan (Treviño)
bfdeb37f6e gatomic: Add Compare and Exchange functions that returns the previous value
Atomic primitives allow to do conditional compare and exchange but also
to get the value that was previously stored in the atomic variable.

Now, we provided an exchange function that allows to do an exchange if
the atomic value matches an expected value but we had no way to know
at the same time what was the value in the atomic at the moment of the
exchange try, an this can be useful in case that the operation fails,
for example if the current value is still acceptable for us, allowing
to do a kind of "OR" check:

  gint old_value;
  gint valid_value = 222;
  while (!g_atomic_pointer_compare_and_exchange_value (&atomic,
                                                       valid_value, 555,
                                                       &old_value)
    {
      if (old_value == 555 || old_value == 222)
        valid_value = old_value;
    }
2022-06-22 23:01:19 +02:00
Marco Trevisan
cb0cc996ee Merge branch 'test-suite-fixes' into 'main'
tests: Various fixes for TAP output of tests

See merge request GNOME/glib!2749
2022-06-22 18:48:59 +00:00