Commit Graph

26427 Commits

Author SHA1 Message Date
Philip Withnall
e34fdb0cd5 docs: Add licensing/copyright data to GVariant specification
The licensing for the original GVariant specification was not specified
in the original PDF.

However, CC-BY-SA-3.0 has been agreed by Allison, the sole copyright
holder, here:

https://gitlab.gnome.org/Teams/documentation/developer-www/-/merge_requests/108/#note_1586866

The diagrams were redrawn by me, so their licensing/copyright status is
clear.

Tested with `reuse lint` to ensure the data is machine-readable.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Simon McVittie
3e1074f403 Merge branch 'misc-variant-fixes' into 'main'
tests: Fix a small leak in the GVariant tests and some minor documentation typos

See merge request GNOME/glib!3062
2022-11-08 15:43:58 +00:00
Philip Withnall
64f5e3ab2d gvariant: Fix some minor typos in documentation comments
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:16:50 +00:00
Philip Withnall
6db82d98d3 tests: Fix a small leak in the GVariant tests
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:16:50 +00:00
Philip Withnall
e2b9e28ece Merge branch 'wip/3v1n0/meson-fix-tests-binary-dependencies' into 'main'
test/meson: Add tests dependencies on built programs, libraries and modules

See merge request GNOME/glib!3015
2022-11-08 12:30:53 +00:00
Philip Withnall
9a0c8a585d Merge branch 'mkenums' into 'main'
glib-mkenums: feature use of previous symbols in evaluation

See merge request GNOME/glib!3043
2022-11-08 11:12:40 +00:00
Simon McVittie
2487fe2258 Merge branch 'fuzz-utf8-validate' into 'main'
fuzzing: Add a fuzz test for g_utf8_validate()

See merge request GNOME/glib!3060
2022-11-07 15:23:37 +00:00
Philip Withnall
42c9e8218b gio: Change content type of zero-sized files to application/x-zerosize
That’s what xdgmime uses for zero-sized files (see `XDG_MIME_TYPE_EMPTY`).

Historically, GLib explicitly used `text/plain` for empty files, to
ensure they would open in a text editor. But `text/plain` is not really
correct for an empty file: the content isn’t text because there is no
content. The file could eventually become something else when written
to.

Text editors which want to be opened for new, empty files should add
`application/x-zerosize` to their list of supported content types.

Users who want to set a handler for `application/x-zerosize` on their
desktop should use
```sh
gio mime application/x-zerosize  # to see the current handler
gio mime application/x-zerosize org.gnome.gedit.desktop  # to set it
```

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

Fixes: #2777
2022-11-07 13:21:28 +00:00
Philip Withnall
46259f612e fuzzing: Add a fuzz test for g_utf8_validate()
Since it’s used extensively and has to handle untrusted arbitrary binary
input.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-07 13:20:32 +00:00
Philip Withnall
4b561a908f Merge branch '2802-drop-g-os-darwin' into 'main'
Revert "meson: Define G_OS_DARWIN when compiling under OSX or iOS"

Closes #2802

See merge request GNOME/glib!3047
2022-11-07 13:03:16 +00:00
Philip Withnall
7c72e24d38 Merge branch 'no-interupt-close' into 'main'
[Darwin] Use the non-cancelable variant of close().

Closes #2783

See merge request GNOME/glib!3041
2022-11-07 13:01:48 +00:00
John Ralls
06650545dd [Darwin] Use the non-cancelable variant of close(). 2022-11-07 13:01:47 +00:00
Philip Withnall
5af339aedf gio: Check __APPLE__ in a few places instead of HAVE_COCOA
`HAVE_COCOA` should be used only in the places where we’re actually
depending on the Cocoa toolkit. It should not be used as a general way
of detecting building on a Darwin-based OS such as macOS.

Conversely, there are a few places in the code where we do want to
specifically detect the Cocoa toolkit (and others where we specifically
want to detect Carbon), so keep `HAVE_COCOA` and `HAVE_CARBON` around.

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

Helps: #2802
2022-11-07 11:30:32 +00:00
Philip Withnall
ad4c59c3c6 docs: Mention __APPLE__ instead of G_OS_DARWIN for detecting Darwin
See discussion on #2802 and in the previous two commits.

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

Fixes: #2802
2022-11-07 11:30:32 +00:00
Philip Withnall
9ebb491d55 Revert "meson: Define G_OS_DARWIN when compiling under OSX or iOS"
This reverts commit e85635daa0.

See the previous revert for rationale.

Fixes: #2802
2022-11-07 11:30:32 +00:00
Philip Withnall
7b52ccbfc4 Revert "gio, glib: Use G_OS_DARWIN for code that is for such environments"
This reverts commit 476e33c3f3.

We’ve decided to remove `G_OS_DARWIN` in favour of recommending people
use `__APPLE__` instead. As per the discussion on #2802 and linked
issues,
 * Adding a new define shifts the complexity from “which of these
   platform-provided defines do I use” to “which platform-provided
   defines does G_OS_DARWIN use”
 * There should ideally be no cases where a user of GLib has to use
   their own platform-specific code, since GLib should be providing
   appropriate abstractions
 * Providing a single `G_OS_DARWIN` to cover all Apple products (macOS
   and iOS) hides the complexity of what the user is actually testing:
   are they testing for the Mach kernel, the Carbon and/or Cocoa user
   space toolkits, macOS vs iOS vs tvOS, etc

Helps: #2802
2022-11-07 11:30:32 +00:00
Simon McVittie
483b6f2214 Merge branch 'heed-warnings-so-they-dont-have-to' into 'main'
ci: Build with -Wnonnull

See merge request GNOME/glib!3058
2022-11-04 20:21:00 +00:00
Ray Strode
57a510df86 Merge branch 'old-fixes-solve-new-problems' into 'main'
macros: generate uniq variable name in _G_BOOLEAN_EXPR()/G_LIKELY()

Closes #1211

See merge request GNOME/glib!3059
2022-11-04 19:29:57 +00:00
Ray Strode
69b410c58a tests: Test g_str_has_prefix inside G_UNLIKELY
g_str_has_prefix uses G_UNLIKELY itself, and up
until recently, G_UNLIKELY could not be nested.

This commit adds a test that nests G_UNLIKELY to
make sure it continues to work going forward.
2022-11-04 15:07:58 -04:00
Thomas Haller
73bd146409 macros: generate uniq variable name in _G_BOOLEAN_EXPR()/G_LIKELY()
This avoids a -Wshadow warning when nesting G_LIKELY() inside
each other due to _g_boolean_var_.

This can be easily encountered when using macros:

```
    #define GET_VALUE(arg) \
        ({ \
           typeof (arg) _arg = (arg); \
           \
           g_assert (_arg); \
           get_value (_arg); \
        })
    g_assert (GET_VALUE (a) > 5);
```

__COUNTER__ is a GCC extension, but the definition of _G_BOOLEAN_EXPR()
is already inside a

  #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)

block.

Closes: #1211
2022-11-04 15:07:58 -04:00
Ray Strode
f11b96f255 ci: Build with -Wnonnull
-Wnonnull is sort of fickle and it's an option a lot of consumers
of glib use.

This commit makes sure it gets used on linux during CI as well, so
we can catch compat problems before they hit our users.
2022-11-04 14:06:48 -04:00
Michael Catanzaro
79b06ab34f Merge branch 'work-back-in-the-work-around' into 'main'
Fix build with -Werror=nonnull

Closes #2807

See merge request GNOME/glib!3057
2022-11-04 17:33:00 +00:00
Ray Strode
48730d2b30 gstrfuncs: Add back x + !x warning workaround
We thought we could drop the x + !x workaround in
commit eea87eff3f but apparently
not.

This commit adds it back, but with an added layer of indirection,
for aesthetics.

Closes: #2807
2022-11-04 13:13:13 -04:00
Ray Strode
05750454d5 gstrfuncs: Use less tristates in g_str_has_*
tri-state conditionals are kind of hard to read, especially
when they're nested.

This commit changes g_str_has_* macros to use if statements
instead.
2022-11-04 13:02:01 -04:00
Simon McVittie
66a6fedca3 Merge branch 'mcatanzaro/#2805' into 'main'
gtask: don't use g_task_set_static_name() unless allowed

Closes #2805

See merge request GNOME/glib!3056
2022-11-04 09:22:43 +00:00
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