Commit Graph

26108 Commits

Author SHA1 Message Date
Emmanuel Fleury
81e4498565 Handle plugable g_modules through RTLD_DEFAULT for NetBSD
fix issue #19
2022-10-25 17:31:25 +02:00
Emmanuele Bassi
86430a27d2 Merge branch 'time' into 'main'
gio/tests/g-file-info: don't assume million-in-one events don't happen

See merge request GNOME/glib!2990
2022-10-20 15:11:56 +00:00
Philip Withnall
2365452d6e Merge branch 'allow-mixed-declarations' into 'main'
meson: Don't explicitly disable mixed declarations and statements

See merge request GNOME/glib!2951
2022-10-20 14:32:23 +00:00
Ross Burton
ed3998b390 gio/tests/g-file-info: don't assume million-in-one events don't happen
The access and creation time tests create a file, gets the time in
seconds, then gets the time in microseconds and assumes that the
difference between the two has to be above 0.

As rare as this may be, it can happen:

$ stat g-file-info-test-50A450 -c %y
2021-07-06 18:24:56.000000767 +0100

Change the test to simply assert that the difference not negative to
handle this case.

This is the same fix as 289f8b, but that was just modification time.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2022-10-20 14:41:56 +01:00
Philip Withnall
1db9066485 Merge branch 'fix-gstrerror-warning' into 'main'
gstrfuncs: Fix a compiler warning in g_strerror()

See merge request GNOME/glib!2956
2022-10-20 12:36:27 +00:00
Philip Withnall
4dcb7f1f9f Merge branch '2753-vasprintf-loop' into 'main'
gprintf: Avoid an infinite loop on ENOMEM in g_vasprintf()

Closes #2753

See merge request GNOME/glib!2944
2022-10-20 12:29:11 +00:00
Marco Trevisan
e49c4b1a9e Merge branch 'python-code-style-again' into 'main'
tests: Fix code style in Python files to satisfy black and flake8

See merge request GNOME/glib!2984
2022-10-20 11:59:53 +00:00
Michael Catanzaro
21a784920d Merge branch 'th/gspawn-no-safe-close' into 'main'
gspawn: avoid race due to retry with EINTR on close()

See merge request GNOME/glib!2947
2022-10-20 11:55:08 +00:00
Philip Withnall
e6fa40bf99 Merge branch 'wip/3v1n0/add-darwin-os' into 'main'
meson: Define G_OS_DARWIN when compiling under OSX or iOS

See merge request GNOME/glib!2981
2022-10-20 11:41:48 +00:00
Philip Withnall
5b01b47c34 Merge branch 'gicon-introspect-vfuncs' into 'main'
gicon: Add introspection for to_tokens / from_tokens vfunc's

See merge request GNOME/glib!2937
2022-10-20 11:39:04 +00:00
Thomas Haller
d6790aecca gspawn: use g_close()
g_close() now is async-signal-safe, as long as we don't request a GError
and pass a valid file descriptor.

Update "gspawn.c" to drop its safe_close() function and use
g_close() instead.
2022-10-20 08:16:52 +02:00
Thomas Haller
3ed7f4d1ed gstdio: make g_close() async-signal-safe under certain conditions
g_close() does something useful. It is not trivial to get EINTR handling of
close() right, in a portable manner. g_close() abstracts this.

We should allow glib users to use the function even in async-signal-safe
contexts, at least if the user heeds the caveat about GError and take care
not to fail assertions.
2022-10-20 08:16:38 +02:00
Marco Trevisan (Treviño)
476e33c3f3 gio, glib: Use G_OS_DARWIN for code that is for such environments
While we preserved the COCOA/CARBON cases when specific libraries are
needed.
2022-10-20 03:37:21 +02:00
Marco Trevisan (Treviño)
e85635daa0 meson: Define G_OS_DARWIN when compiling under OSX or iOS
It has enough differences to expose it as an unix-subtype.
2022-10-20 03:37:03 +02:00
Thomas Haller
6418db829b gspawn: avoid race due to retry with EINTR on close()
Retry on EINTR is wrong on many OS, including Linux. See the comment
in g_close() why that is.

As we cannot use g_close() after fork, we had safe_close(). This had the
wrong retry loop on EINTR. Drop that.

This was especially problematic since commit 6f46294227 ('gspawn: Don’t
use g_close() in async-signal-safe context'). Before, safe_close() was
only called after fork, where there is only one thread and there is no
concern about a race.

This patch only exists for easier backporting of the bugfix. The code
will be reworked further next.

Fixes: 6f46294227 ('gspawn: Don’t use g_close() in async-signal-safe context')
2022-10-19 20:54:18 +02:00
Philip Withnall
06029c5945 Merge branch 'remove-docs-artifacts' into 'main'
ci: Do not store docs artifacts

See merge request GNOME/glib!2985
2022-10-19 18:21:51 +00:00
Matthias Clasen
65536b079d gstrfuncs: Fix a compiler warning in g_strerror()
MSVC is complaining about this code. Let’s try
to help it see the light.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2800
2022-10-19 14:53:45 +01:00
Marco Trevisan (Treviño)
782625bd26 ci: Do not store docs artifacts
This was discussed in a previous MR [1], but it apparently went in
during rebase

[1] https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2820#note_1502207
2022-10-19 15:52:22 +02:00
Philip Withnall
4b6cc2d87b Merge branch 'gtask-bitfields-fix' into 'main'
gtask: Use unsigned bit-field struct values to avoid warnings

See merge request GNOME/glib!2979
2022-10-19 11:32:25 +00:00
Philip Withnall
59541e335a tests: Fix code style in Python files to satisfy black and flake8
This should make the style-check-diff CI job happy again.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-19 12:28:08 +01:00
Philip Withnall
08cb200aec Merge branch 'halfline-no-spawn' into 'main'
A couple of test fixes on OS X

See merge request GNOME/glib!2978
2022-10-19 10:20:34 +00:00
Philip Withnall
7cc95e0211 Merge branch 'wip/pwithnall/2785-macos-fd-close-test-failure' into 'main'
gstdio: Temporarily disable g_close() warning on macOS

See merge request GNOME/glib!2977
2022-10-19 09:52:29 +00:00
Philip Withnall
0839556904 Merge branch 'gmessages-handle-unused-write-results' into 'main'
gmessages: Handle unused results from fputs and fwrite

Closes #2758

See merge request GNOME/glib!2910
2022-10-19 09:23:52 +00:00
Ray Strode
8f85fa163b tests: Check for public.text not text/plain on OSX
The "content type" on OSX is a Uniform Type Identifier not a MIME
type, so make sure to use the right format in the empty file test.
2022-10-18 16:02:49 -04:00
Ray Strode
9d0d30c9d2 tests: Don't run du on osx
The du command that ships on OS X doesn't understand
--bytes, so don't try to use du on that platform.
2022-10-18 16:02:02 -04:00
Marco Trevisan (Treviño)
4398d140c7 gtask: Use unsigned bit-field struct values to avoid warnings
In recent Clang we may get a build warning as per:

  ../gio/gtask.c: warning: implicit truncation from 'int' to a
    one-bit wide bit-field changes value from 1 to -1
    [-Wsingle-bit-bitfield-constant-conversion]

This is because we use gboolean (and thus a signed type) for bit-fields.
Now, this is not an issue in practice for the way we're using them, but
still better to mute such compiler warns in the right way.
2022-10-18 21:28:00 +02:00
Ray Strode
11ca3da091 Merge branch 'halfline/test-case-pipe-confusion' into 'main'
tests/desktop-app-info: Make sure scripts writes to the right end of the pipe

See merge request GNOME/glib!2969
2022-10-18 17:57:52 +00:00
Marco Trevisan (Treviño)
977b734e0b gmessages: Handle unused results from fputs and fwrite
Fixes: #2758
2022-10-18 19:41:18 +02:00
Marco Trevisan
ba961b90d9 Merge branch 'log-fallback-handler-newline' into 'main'
gmessages: Add missing trailing newline in fallback log handler

See merge request GNOME/glib!2945
2022-10-18 16:38:59 +00:00
Marco Trevisan
2c90a563ae Merge branch 'unix-streams-fixes' into 'main'
tests: Fix race condition on cancellation in unix-streams test

See merge request GNOME/glib!2963
2022-10-18 16:30:19 +00:00
Marco Trevisan
337763bcf3 Merge branch 'always-sniff-xdg-mime' into 'main'
glocalfileinfo: Ensure we always sniff some data to get the content type

Closes #2742

See merge request GNOME/glib!2887
2022-10-18 16:27:25 +00:00
Ray Strode
04c8a6bc61 Revert "tests: Temporarily disable desktop-app-info terminal test on FreeBSD"
Since we no longer require /proc for the desktop-app-info test, we can
run it on FreeBSD again.

This reverts commit 3235eee0e2.
2022-10-18 12:15:10 -04:00
Ray Strode
4657e9bf60 tests/desktop-app-info: Use named pipe instead of /proc
Freebsd doesn't always have /proc mounted, so relying on
/proc for the tests isn't ideal.

This commit changes the desktop-app-info tests to use
mkfifo instead of /proc/../fd/.. to relay terminal
arguments.

Might help with this error message I'm seeing in CI:

/tmp/bin-path-H1UQT1/gnome-terminal: cannot create /proc/38961/fd/6: No such file or directory
2022-10-18 12:15:10 -04:00
Marco Trevisan (Treviño)
846e68befd glocalfileinfo: Ensure we always sniff some data to get the content type
In case the XDG database is not initialized yet we may try to sniff a
0-length data, making our content-type routines to mark non-empty files
as `application/x-zerosize`.

This is wrong, so in case the sniff size is not set, let's just
try to read the default value. To avoid false-application/x-zerosize
results (that are not something we want as per legacy assumptions).

See: https://bugzilla.gnome.org/show_bug.cgi?id=755795

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2742
2022-10-18 17:46:38 +02:00
Marco Trevisan
066ca6b042 Merge branch 'coverity-issues' into 'main'
Fix a couple of minor Coverity issues

See merge request GNOME/glib!2976
2022-10-18 15:03:06 +00:00
Philip Withnall
9965d0cdc7 Merge branch '2782-gvariant-recursion-typedecl-fix' into 'main'
gvariant-parser: Reject deeply-nested typedecls in text form variants

Closes #2782

See merge request GNOME/glib!2974
2022-10-18 14:50:25 +00:00
Marco Trevisan
baa766295d Merge branch 'fix-desktop-app-info' into 'main'
tests: Fix minor race in desktop-app-info terminals test

See merge request GNOME/glib!2968
2022-10-18 14:44:42 +00:00
Philip Withnall
5190354ad9 gstdio: Temporarily disable g_close() warning on macOS
It causes the tests to fail, which suggests some latent FD handling bug
on macOS (but not other platforms).

Unfortunately I’m unable to debug that due to not having access to a
macOS machine, and it’s blocking CI for the rest of the project.

So disable it on macOS for now, until someone with access to a macOS
machine can take a look.

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

Helps: #2785
2022-10-18 15:41:30 +01:00
Marco Trevisan
f8674c1d4c Merge branch 'g_str_has_optimization' into 'main'
Optimize g_str_has_*() functions to  detect static arguments

Closes #24

See merge request GNOME/glib!2859
2022-10-18 14:15:56 +00:00
Philip Withnall
ab774d6e8b gbinding: Explicitly ignore return values from g_param_value_validate()
They only indicate whether the value had to be modified to keep it
valid. That doesn’t matter when binding values.

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

Coverity CID: #1498116, #1498114
2022-10-18 15:12:31 +01:00
Philip Withnall
4fca3bba8f gregex: Remove an unreachable return statement
Spotted by Coverity.

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

Coverity CID: #1497916
2022-10-18 15:05:30 +01:00
Philip Withnall
3e313438f1 gvariant-parser: Reject deeply-nested typedecls in text form variants
Return `G_VARIANT_PARSE_ERROR_RECURSION` from `g_variant_parse()` if a
typedecl is found within a text-form variant which would cause any part
of the variant to exceed the maximum allowed recursion/nesting depth.

This fixes an oversight when `G_VARIANT_MAX_RECURSION_DEPTH` was
implemented, which allowed typedecls to effectively multiply the size of
an array if `g_variant_parse()` was parsing a text-form variant without
a top-level concrete type specified.

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

Fixes: #2782
oss-fuzz#49462
2022-10-18 14:52:32 +01:00
Philip Withnall
9164fdcbbb Merge branch 'mcatanzaro/cast-checks-oopsie' into 'main'
Fix build when G_DISABLE_CAST_CHECKS is defined to empty string

See merge request GNOME/glib!2967
2022-10-18 13:45:03 +00:00
Ray Strode
2e627803e7 Merge branch 'fix-GTimeZone-in-toolbx' into 'main'
gtimezone: Reject weird /etc/localtime configurations

See merge request GNOME/glib!2955
2022-10-18 13:39:44 +00:00
Philip Withnall
8d02465ea8 Merge branch 'th/hash-steal-doc' into 'main'
ghash: comment g_hash_table_steal_extended() about not destroying key/value

See merge request GNOME/glib!2965
2022-10-18 13:37:14 +00:00
Philip Withnall
1f00fc9212 Merge branch 'th/g-close-ebadf' into 'main'
gstdio: fail assertion in g_close() for invalid file descriptor (EBADF)

See merge request GNOME/glib!2964
2022-10-18 13:19:26 +00:00
Ray Strode
6265b2e6f7 gtimezone: Reject weird /etc/localtime configurations
At the moment, glib assumes that if /etc/localtime is a symlink,
that it's a symlink to zoneinfo file.

Toolbx containers add an extra layer of indirection though, making
it a symlink to a symlink to a zoneinfo file.

This commit deals with the problem, by performing additional checks
on /etc/localtime and ignoring it if those check fail, falling back
instead to reading /etc/timezone.
2022-10-18 08:59:24 -04:00
Michael Catanzaro
8c54de8fa0 Fix build when G_DISABLE_CAST_CHECKS is defined to empty string
The usual use of G_DISABLE_CAST_CHECKS is to define it without giving it
a value. The value was never looked at until
f946e45a0c, where I decided it would be
cool to ignore it if defined to 0. But this broke the original usage, so
we need to revert that.

I thought it would be a good idea to look at the value in order to give
applications an off switch for the new behavior, so you could continue
to build optimized builds with cast checks enabled. We could still try
to find a way to do that in the future if desired, e.g. by introducing a
new G_ENABLE_CAST_CHECKS definition. But this doesn't seem especially
important. G_DISABLE_CAST_CHECKS is not documented anyway, so how we
handle cast checks is entirely up to GLib.
2022-10-18 13:58:14 +01:00
Thomas Haller
4a709d0b46 ghash: comment g_hash_table_steal_extended() about not destroying key/value
The previous text was technically correct, but not very clear what
happens with the ownership of the key/value if it was not returned.
Elaborate on the fact, that the key/value is never destroyed, even if
not requested by the user.

I intuitively expected the function to behave differently, that is, to
destroy the key/value if (and only if) it was not returned. That is,
when the function does not return a pointer, then it would destroy it.
That would seem more consistent to me, where ownership is either
transferred to the caller, or the resource destroyed during the steal.

On the other hand, the existing behaviors is:

- is consistent with g_hash_table_steal() and never destroys key/value.
- behaves the same, regardless whether the key/value was returned.

So the existing behavior may be better.

Just elaborate on that detail in the doc.
2022-10-18 13:57:43 +01:00
Thomas Haller
d5dc7d266f gstdio: fail assertion in g_close() for invalid file descriptor (EBADF)
An application must keep track of the file descriptors that it
has. Closing an invalid, non-negative file descriptor is usually
a bug, because it indicates somebody messed up the tracking.

On a single threaded application it may be fine, but EBADF is always a bug
in a multi threaded application because another thread might race
reusing the bad file descriptor. With GDBus and other glib API, it is very
common that your application has multiple threads running and this is
in fact a bug.

The assertion failure does not necessarily indicate that the bug
is in the caller. It could have been another part of the application
that wrongly closed the file descriptor.
2022-10-18 13:57:14 +01:00