Commit Graph

26502 Commits

Author SHA1 Message Date
Michael Catanzaro
24f2cfba25 gtask: don't use g_task_set_static_name() unless allowed
Need to check GLIB_VERSION_MIN_REQUIRED before inlining use of something
newer.

Fixes #2805
2022-11-03 19:06:40 -05:00
Ray Strode
98c3c3397c Merge branch 'sometimes-theres-extra-strings-attached' into 'main'
gstrfuncs: Make g_str_has_* more robust against non-idempotent inputs

Closes #2784

See merge request GNOME/glib!3054
2022-11-03 23:24:44 +00:00
Ray Strode
eea87eff3f gstrfuncs: Make g_str_has_* more robust against non-idempotent inputs 2022-11-03 23:24:44 +00:00
Ray Strode
877e86895e Merge branch 'wip/smcv/msvc-ebadf' into 'main'
fileutils test: Use no-op invalid-parameter handler when exercising EBADF

See merge request GNOME/glib!3055
2022-11-03 21:26:57 +00:00
Simon McVittie
1dd11faaea fileutils test: Use no-op invalid-parameter handler when exercising EBADF
This is basically !3036, but wasn't included there because !3036
and !3027 were developed in parallel.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-03 20:39:37 +00:00
Simon McVittie
201c920cbd Merge branch 'fix-fileutils-test' into 'main'
Clean up Windows Invalid Parameter Handler setup and fix fileutils test

Closes #2800

See merge request GNOME/glib!3036
2022-11-02 22:59:14 +00:00
Simon McVittie
65c7758087 Merge branch 'wip/smcv/autofd' into 'main'
gstdio: Preserve errno in g_autofd, document async-signal safety

See merge request GNOME/glib!3027
2022-11-02 21:39:53 +00:00
Simon McVittie
f1f711dc77 tests: Test EBADF and errno handling when closing fds
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 21:26:34 +00:00
Simon McVittie
81130a6e3f gstdio: Document async-signal-safety of g_clear_fd and g_autofd
g_clear_fd wraps g_close and is async-signal-safe under essentially the
same circumstances. If fd_ptr already pointed to a negative number, then
g_clear_fd doesn't call g_close, and is still async-signal-safe.

g_autofd passes a NULL error pointer to g_clear_fd, so it is
async-signal-safe, as long as no programming error occurs.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 21:26:34 +00:00
Simon McVittie
e231132fc3 gstdio: Document errno behaviour of g_clear_fd
g_clear_fd has the same interaction with errno as g_close or most libc
functions: on success it has an unspecified effect on errno, and on
failure (other than programming error) it sets errno to indicate the
reason for failure.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 21:26:34 +00:00
Simon McVittie
088d8b4359 gstdio: Preserve errno when calling g_clear_fd() from g_autofd
g_clear_fd() can alter errno, but it's unexpected for leaving a scope
to change errno.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 21:26:34 +00:00
Nathan Follens
e2e55a13d1 Update Dutch translation
(cherry picked from commit 5ee5900459)
2022-11-02 19:09:08 +00:00
Philip Withnall
fca52b7914 ci: Update git paths to reflect new GitLab URI
The GitLab instance has been moved around, so the SSH clone URI for
repositories has changed. Change that in `CONTRIBUTING.md`, and also
change to using a relative path in `.gitmodules` to insulate from
similar URI changes in future.

Changing to a relative path in `.gitmodules` also enables the CI to use
submodules more easily: https://docs.gitlab.com/ee/ci/git_submodules.html

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-02 16:49:51 +00:00
Philip Withnall
ea0e9bf1f1 ci: Rename style-check-diff to style-check-advisory
To better reflect its purpose.

This will also help distinguish it from a job being added in a following
commit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-02 16:49:51 +00:00
Michael Catanzaro
213859e33e Merge branch 'darwin-evolves-to-fd-walk' into 'main'
gspawn: Provide less brute force fdwalk implementation on macOS

See merge request GNOME/glib!3040
2022-11-02 16:16:34 +00:00
Chun-wei Fan
41d8ed37cd glib/tests/meson.build: Expect fileutils to pass on Windows
The underlying issue was fixed, so expect that to pass.
2022-11-03 00:11:45 +08:00
Chun-wei Fan
4f426c56d0 fileutils.c: Fix the clearfd test on Windows
...when the test program aborts while checking the FD's were indeed
closed, since we need to override the invalid parameter handler to do
such checks, if the CRT demands so, so that the test program will
proceed normally.

This will fix issue #2800.
2022-11-03 00:11:45 +08:00
Chun-wei Fan
9bcc9405d7 glib: Port to the private invalid parameter handler APIs
Use the newly-added private APIs added in the previous commit so that we
can clean up the code a bit.
2022-11-03 00:11:45 +08:00
Chun-wei Fan
08e0fef632 glib-private.c: Add private API to override invalid parameter handler
...if supported, as in the previous commit.  We will eventually use
these private API to override the invalid parameter handler as needed
in the other parts of GLib and the tests.

We also now use _set_thread_local_invalid_parameter_handler()
instead of just _set_invalid_parameter_handler() to be safer, if
that is available.

This can be expanded upon in the future if we desire to use a stricter
or more customized invalid parameter handler.
2022-11-03 00:11:45 +08:00
Chun-wei Fan
b92b17f021 build: Check for invalid parameter overriding on Windows
Allow one to override the invalid parameter handler if we have the
following items:

* _set_invalid_parameter_hander() or
  _set_thread_local_parameter_handler()
* _CrtSetReportMode() as a function or macro

Currently, we are doing this on Visual Studio to allow GSpawn to work on
Windows as well as having the log writer support color output, as we
might be passing in file descriptors that are invalid, which will cause
the CRT to abort unless the default invalid parameter handler is
overridden.
2022-11-03 00:11:45 +08:00
Ray Strode
274150a391 gspawn: Provide less brute force fdwalk implementation on macOS
It seems macOS has a way to query open fds for a process, so this
commit tries to use it, instead of just trying all fds between
0 and $BIGNUMBER.
2022-11-02 11:31:08 -04:00
Simon McVittie
92730c6226 Merge branch 'revert-it-all-and-let-god-sort-em-out' into 'main'
Revert "Handling collision between standard i/o file descriptors and newly created ones"

Closes #2795, #2785, and #16

See merge request GNOME/glib!3029
2022-11-02 14:34:39 +00:00
Ray Strode
aaae515e13 Revert "gstdio: Temporarily disable g_close() warning on macOS"
This reverts commit 5190354ad9.

Now that g_close isn't called from gspawn anymore, we can reenable
the g_close warning on macOS.

Closes: #2785
2022-11-02 09:40:28 -04:00
Ray Strode
168fd4f2b3 gspawn: Don't use g_close when doing fdwalk to close potentially invalid fds
Some platforms (e.g., macOS) don't currently have a way
to close only open fds in preparation for exec. On these
platforms, glib just bites the bullet and calls g_close for
the whole fileno range.

g_close only allows valid fds to be given to it, though.

This commit ensures close is called instead of g_close on
those platforms by splitting the safe_fdwalk implementation
that operates on invalid fds off to its own function and
only using it as a fall back.
2022-11-02 09:36:26 -04:00
Ray Strode
ac4dbc82e1 gspawn: Make sure pipe fds end up at the right place
It's possible when gspawn sets up its pipes for standard io,
that the pipe fds themselves end up in the standard io range
reserved for stdin, stdout, stderr.

This commit protects against that problem by relocating the
fds up, outside of the range.

Closes: #16
2022-11-02 09:36:26 -04:00
Ray Strode
e3ae492550 tests: Add g_spawn_test for when stdio fd range is exposed
This commit adds a test to make sure GSpawn still works even
if fds 0, 1, and 2 are closed before it's run.
2022-11-02 09:36:26 -04:00
Ray Strode
2399585860 gspawn: Rename CHILD_DUP2_FAILED to CHILD_DUPFD_FAILED
The error code is already used for both F_DUPFD and dup2
already, and having dup2 in the name is oddly specific.

This renames the error code for clarity.
2022-11-02 09:06:34 -04:00
Ray Strode
e5782dcafc glib-unix: Add test to make sure g_unix_open_pipe will intrude standard range
Now that we know it's a bad idea to avoid the standard io fd range
when getting pipe fds for g_unix_open_pipe, we should test to make sure
we don't inadvertently try to do it again.

This commit adds that test.
2022-11-02 09:06:34 -04:00
Ray Strode
dad97d24d5 Revert "Handling collision between standard i/o file descriptors and newly created ones"
g_unix_open_pipe tries to avoid the standard io fd range
when getting pipe fds. This turns out to be a bad idea because
certain buggy programs rely on it using that range.

This reverts commit d9ba615090

Closes: #2795
Reopens: #16
2022-11-02 09:06:34 -04:00
Philip Withnall
451ed353f5 Merge branch 'wip/smcv/tests-license' into 'main'
Add a SPDX LicenseRef for the license historically used for tests

See merge request GNOME/glib!3049
2022-11-02 12:55:50 +00:00
Simon McVittie
2673b262aa custom-dispatch: Change SPDX-License-Identifier to match license grant
The SPDX-License-Identifier said LGPL-2.1-or-later, but the license
grant was a permissive license, which we now identify as
LicenseRef-old-glib-tests.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 12:35:45 +00:00
Simon McVittie
32b0dd24e3 Add a SPDX LicenseRef for the license historically used for tests
Some of GLib's unit tests are under an apparently GLib-specific
permissive license, vaguely similar to the BSD/MIT family but with the
GPL's lack-of-warranty wording. This is not on SPDX's list of
well-known licenses, so we need to use a custom license name prefixed
with LicenseRef if we want to represent this in SPDX/REUSE syntax.

Most of the newer tests seem to be licensed under LGPL-2.1-or-later
instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 12:34:19 +00:00
Philip Withnall
7ee767213b Merge branch 'mcatanzaro/#2799' into 'main'
gproxyresolver: lookup_finish() should better parallel lookup_async()

Closes #2799

See merge request GNOME/glib!3045
2022-11-02 09:47:32 +00:00
Philip Withnall
0e9e51767a Merge branch 'variant-docs' into 'main'
docs: Convert GVariant Specification to reStructuredText

See merge request GNOME/glib!3044
2022-11-02 09:40:24 +00:00
Xavier Claessens
f6edb52bda Merge branch 'wip/3v1n0/some-meson-fixmes' into 'main'
meson: Handle various build system FIXME's

See merge request GNOME/glib!3012
2022-11-01 23:36:04 +00:00
Michael Catanzaro
7f85fd126b gproxyresolver: lookup_finish() should better parallel lookup_async()
In g_proxy_resolver_lookup_async() we have some error validation that
detects invalid URIs and directly returns an error, bypassing the
interface's lookup_async() function. This is great, but when the
interface's lookup_finish() function gets called later, it may assert
that the source tag of the GTask matches the interface's lookup_async()
function, which will not be the case.

As suggested by Philip, we need to check for this situation in
g_proxy_resolver_lookup_finish() and avoid calling into the interface
here if we did the same in g_proxy_resolver_lookup_async(). This can be
done by checking the source tag.

I added a few new tests to check the invalid URI "asdf" used in the
issue report. The final case, using async GProxyResolver directly,
checks for this bug.

Fixes #2799
2022-11-01 13:40:35 -05:00
Emmanuele Bassi
c33edff7fa Apply 2 suggestion(s) to 1 file(s) 2022-11-01 17:38:22 +00:00
Patrick Monnerat
f2c590f494 tests/mkenums.py: add a test case for symbolic expression evaluation 2022-11-01 16:06:20 +01:00
Patrick Monnerat
96fa9752b2 glib-mkenums: evaluate private symbols too
This allows them to be referenced in other symbols value computation.

In addition, this fixes the automatically assigned value of a public
symbol that is preceded by a private one:

        typedef enum {
          /*< private >*/
          ENUM_VALUE_PRIVATE,
          /*< public >*/
          ENUM_VALUE_PUBLIC,                    <--- value is 1, not 0.
        } SomeExampleEnum;
2022-11-01 15:46:13 +01:00
Philip Withnall
993325400d Merge branch 'task-strdup-avoidance' into 'main'
task: Don't overwrite source names

See merge request GNOME/glib!2869
2022-11-01 13:26:17 +00:00
Philip Withnall
088df783c0 docs: Convert GVariant Specification to reStructuredText
This is a verbatim conversion of the GVariant Specification from
https://people.gnome.org/~desrt/gvariant-serialisation.pdf /
https://raw.githubusercontent.com/ostreedev/gvariant-rs/master/docs/gvariant-serialisation.pdf
to reStructuredText.

This is for several reasons:
 1. The canonical copy has gone offline due to people.gnome.org being
    shut down.
 2. GLib is the reference implementation of GVariant, so should probably
    host the specification (unless someone wants to host it on
    freedesktop-specs).
 3. Moving it out of a PDF and into reStructuredText should allow for
    amendments. The specification has a few problems, typos and
    oversights in its original form, and it would be good to canonically
    fix them without having to write a separate addendum document.

This conversion is verbatim, and does not change the content of the
document at all, even to fix typos and broken links (which there are a
small number of in the PDF).

This describes what I’m labelling as version 1.0 of the GVariant
serialisation format. Updates to the specification can bump this version
number, in subsequent commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-01 13:12:53 +00:00
Matthias Clasen
13e48ff963 tests: Tweak the task tests
Tweak the g_task_set_name test to use a non-literal string,
so we don't test g_task_set_static_name twice.
2022-11-01 11:48:52 +00:00
Matthias Clasen
525e3953ef tests: Add a test for g_task_set_static_name()
The test checks that the original string
is returned by g_task_get_name().
2022-11-01 11:48:46 +00:00
Matthias Clasen
99c7d60869 gtask: Add g_task_set_static_name()
Similar to g_source_set_static_name, this avoids
strdup overhead for debug-only information in
possibly hot code paths.

We also add a macro wrapper for g_task_set_name that
uses __builtin_constant_p to decide whether to use
g_task_set_name or g_task_set_static_name.
2022-11-01 11:48:38 +00:00
Matthias Clasen
794ee60306 gdbusconnection: Set a name on all sources
We already set names on most sources, this
one was just forgotten. This lets us set
a static name, and prevents g_task_attach_source
from setting a non-static one.
2022-11-01 11:48:33 +00:00
Matthias Clasen
01f2c5aec9 gtask: Don't overwrite source names
Only set a name in g_task_attach_source
if the source does not already have one.

Including a new test by Philip Withnall.
2022-11-01 11:48:08 +00:00
Philip Withnall
110cddb90c Merge branch 'wip/smcv/os-detect' into 'main'
docs: Mention platform-specific predefined macros

See merge request GNOME/glib!2997
2022-11-01 11:00:03 +00:00
Philip Withnall
debf3e4a87 Merge branch 'sandbox-check' into 'main'
gio: Create a sandbox checking function

See merge request GNOME/glib!3037
2022-11-01 10:45:05 +00:00
Simon McVittie
871237b9d5 docs: Mention platform-specific predefined macros
The platform-specific predefined macros provided by various compilers
sometimes capture subtle differences of meaning, like the distinction
between the Linux kernel and a glibc-based (GNU/Linux) user-space.
It would be difficult to capture those subtleties in GLib-specific
convenience macros, particularly for platforms that we don't use
ourselves.

Instead, recommend that anyone who is already writing platform-specific
code should use the platform-specific predefined macros directly.

Alternative to !2986.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-01 10:40:37 +00:00
Robert Ancell
bfd7074dfc gio: Fix formatting 2022-11-01 10:20:36 +00:00