Commit Graph

26560 Commits

Author SHA1 Message Date
Simon McVittie
2b4977635c gthread: Fully initialize GThreadFunctions structure in test
The macOS CI builds with -Werror=missing-field-initializers by default,
making incomplete initializers a compile-time error (even though their
meaning is well-defined: missing fields are initialized as if with
.field = 0).

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2812
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-14 09:43:29 +00:00
Xavier Claessens
b65d6f497d gio: Fix missing visibility header dependency 2022-11-12 10:20:49 -05:00
Philip Withnall
f64f88baae Merge branch 'gtask-must-have-result' into 'main'
gtask: Warn if a GTask is finalised without returning

See merge request GNOME/glib!385
2022-11-10 22:26:18 +00:00
Marco Trevisan
240c99d5a4 Merge branch 'coverage-exclusions' into 'main'
ci: Exclude copylibs and fuzz tests from code coverage

See merge request GNOME/glib!3064
2022-11-10 15:52:48 +00:00
Marco Trevisan
57ee7f914c Merge branch 'gthread-tests' into 'main'
tests: Add some trivial tests for g_thread_init()

See merge request GNOME/glib!3065
2022-11-10 15:51:08 +00:00
Philip Withnall
5585d15d9c tests: Add some trivial tests for g_thread_init()
It’s deprecated, but the big red 0/0/0 line for the `glib/gthread`
directory in the lcov output for GLib is driving me nuts.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10 15:33:34 +00:00
Philip Withnall
e960529532 ci: Exclude copylibs and fuzz tests from code coverage
The fuzz tests are run on a separate CI system, and we don’t care what
their code coverage is. The only reason they’re run on our CI systems at
all is as a smokecheck. They are not unit tests that we want to check
are running every line.

Similarly, exclude copylibs/subprojects as GLib is not responsible for
testing them. They have (or should have) their own unit tests and code
coverage metrics in their upstreams.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10 14:56:34 +00:00
Philip Withnall
9b68c31b38 tests: Add a missing g_task_return_boolean() in gdbus-server-auth tests
Otherwise the task never returned a value.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/385

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10 14:25:47 +00:00
Philip Withnall
fe89940572 gtask: Emit a debug message if a GTask is finalised without returning
This typically indicates a bug in the program, where a GTask has been
created, but a bug in the control flow has caused it to not return a
value.

There is one situation where it might be legitimate to finalise a GTask
without returning: if an error happens in your *_async() start function
after you’ve created a GTask, but before the async operation returns to
the main loop; and you report the error using g_task_report_*error()
rather than reporting it using the newly constructed GTask.

Another situation is where you are just using GTask as a convenient way
to move some work to another thread, without the complexity of creating
and running your own thread pool. GDBus does this with
g_dbus_interface_method_dispatch_helper(), for example.

In most other cases, it’s a bug. Emit a debug message about it, but not
a full-blown warning, as that would create noise in the legitimate
cases.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2022-11-10 14:25:47 +00:00
Philip Withnall
7077e7d819 build: Post-release version bump
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10 09:27:34 +00:00
Philip Withnall
069fd1d8cf
2.75.0
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10 09:18:47 +00:00
Philip Withnall
116f84910d docs: Fix date formatting for a few entries in NEWS
ISO 8601, please.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10 09:15:44 +00:00
Philip Withnall
1d7dfb68e8 Merge branch 'type-deprecation' into 'main'
Add G_TYPE_FLAG_DEPRECATED

See merge request GNOME/glib!2993
2022-11-09 12:24:06 +00:00
Matthias Clasen
fd0dd9e93c gobject: Add G_TYPE_FLAG_DEPRECATED
This can be used to mark entire types as deprecated,
and trigger a warning when they are instantiated
and `G_ENABLE_DIAGNOSTIC=1` is set in the environment.

There's currently no convenient macros for defining
types with the new flag, but you can do:

```c
_G_DEFINE_TYPE_EXTENDED_BEGIN (GtkAppChooserWidget,
                               gtk_app_chooser_widget,
                               GTK_TYPE_WIDGET,
                               G_TYPE_FLAG_DEPRECATED)
...
_G_DEFINE_TYPE_EXTENDED_END ()
```

Includes a unit test by Philip Withnall.
2022-11-09 12:07:31 +00:00
Philip Withnall
abdb81efa2 Merge branch 'slow-slow-slow-your-boat' into 'main'
tests: Shorten internal codegen test timeout

See merge request GNOME/glib!3050
2022-11-08 19:13:09 +00:00
Ray Strode
4a00ac91c6 tests: Shorten internal codegen test timeout
the gio dbus codegen test has 10 test cases in it.
Each test case is given 100 seconds to complete.

That is far longer than they should need.

Furthermore, the entire test is only given 60s
to complete.

This commit makes the internal timeout more consistent
with the external timeout, by giving each of the 10
test cases 6 seconds instead of 100s.
2022-11-08 13:08:53 -05:00
Philip Withnall
6e57afdefd Merge branch '2782-variant-maybe-wrapper-speedup' into 'main'
gvariant-parser: Speed up maybe_wrapper() by an order of magnitude

Closes #2782

See merge request GNOME/glib!3061
2022-11-08 17:11:07 +00:00
Philip Withnall
482e9cd9e3 Merge branch 'reuse-regressions-ci' into 'main'
ci: Add a CI check for REUSE-compliant licensing/copyright headers

See merge request GNOME/glib!3051
2022-11-08 16:30:12 +00:00
Philip Withnall
9ae59bd647 gvariant-parser: Speed up maybe_wrapper() by an order of magnitude
This further helps with the potential denial of service problem in
issue #2782 / oss-fuzz#49462 / oss-fuzz#20177.

Instead of allocating a new `GVariant` for each nesting level of
maybe-types, allocate a single `GVariant` and give it the fully-nested
maybe type as its type. This has to be done in serialised form.

This prevents attackers from triggering O(size of container × typedecl
depth) allocations.

This is a follow up to commit 3e313438f1,
and includes a test.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2782
oss-fuzz#20177
oss-fuzz#49462
2022-11-08 16:14:02 +00:00
Philip Withnall
1e7b20d68a Merge branch 'variant-spec-updates' into 'main'
docs: Add licensing/copyright data to GVariant specification and fix various formatting issues

See merge request GNOME/glib!3048
2022-11-08 16:13:59 +00:00
Philip Withnall
b906d470c7 ci: Add a CI check for REUSE-compliant licensing/copyright headers
This doesn’t enforce licensing/copyright headers to be present on all
files, but does check that at least a minimum number of files are
correct.

This should help avoid new files being added without appropriate
licensing information in future.

The baseline is set at what `reuse lint` outputs for me at the moment.

See https://reuse.software/tutorial/#step-2 for information about how to
add REUSE-compliant licensing/copyright to files.

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

Helps: #1415
2022-11-08 15:50:59 +00:00
Philip Withnall
b7c497eedb docs: Fix a broken link in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
e039a30ef1 docs: Add a manual revision history to the GVariant Specification
This will make it clear what the bigger changes are between versions.
Kind of like a `NEWS` file for the specification.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
f518d78fd7 docs: Add links to the D-Bus specification to the GVariant Specification
This should clarify object paths and signatures a little, if anyone
needs that. This introduces no semantic changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
227bb51a74 docs: Change ‘DBus’ to ‘D-Bus’ in the GVariant Specification
That’s how it’s meant to be formatted.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
bf4bab98f7 docs: Fix forall formatting in GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
106ef532fc docs: Improve Python code snippet formatting in GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
fa823ea3b4 docs: Minor improvement of word choice in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
950e8991cd docs: Remove another dangling reference from the GVariant Specification
This is another reference to an omitted part of Allison’s thesis.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
6d8349a9ff docs: Fix subsection capitalisation consistency in GVariant Spec
The other subheadings here are in Title Case.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
59620c9cf8 docs: Fix a cross-reference to a Figure in the GVariant Specification
reStructuredText doesn’t support cross-references unless always built
with Sphinx (as I understand it). `rst2html5` doesn‘t support them.

So reword this (currently manual) cross-reference so it’s less awkward.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
aa568abb97 docs: Fix a minor typo in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
ca45f84789 docs: Fix references to omitted requirements in GVariant Specification
I believe the specification was originally a shorter extract of
Allison’s thesis. This left a few dangling references to requirements
which were listed in a part of the thesis not included in the
specification.

Reword them slightly so they’re not quite so awkward.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
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