Commit Graph

31847 Commits

Author SHA1 Message Date
Philip Withnall
c76b9bc72e girepository: Fix various precondition failure return values to typecheck
This fixes various `-Wsign-conversion` warnings in `giarginfo.c` and
related files.

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

Helps: #3405
2025-04-30 13:18:45 +01:00
Philip Withnall
cdca951d06 gdump: Fix some GError -Wsign-conversion warnings
Because of the generic nature of `GError`, `g_set_error()` has to take
an `int`, but `g_file_error_from_errno()` returns a `GFileError`. The
macOS CI runner decides that’s a good reason to emit
`-Wsign-conversion`.

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

Helps: #3405
2025-04-30 13:18:38 +01:00
Philip Withnall
e662421d3a girnode: Make an internal struct member’s type more specific
This struct is only ever heap allocated, and enums are always the same
size as an int (or unsigned int), so it won’t change size.
The struct doesn’t correspond to any mmapped structure from a
typelib file.

This should fix some `-Wsign-conversion` warnings (curiously only seen
on the macOS CI runner) by using the most specific type.

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

Helps: #3405
2025-04-30 13:18:31 +01:00
Philip Withnall
eaf27c0649 Merge branch 'macos_ci' into 'main'
Update macOS job for new CI runner

See merge request GNOME/glib!4613
2025-04-29 20:56:59 +00:00
René de Hesselle
dc23a17fb1 ci: Update macOS job for new CI runner
Remove settings no longer required on an ephemeral runner (redirecting
cache locations etc.).

Adjust cache settings.
2025-04-29 22:38:45 +02:00
Philip Withnall
c22642589b Merge branch 'wip/shell-parse-empty-comment' into 'main'
shell: Handle empty comment gracefully

See merge request GNOME/glib!4615
2025-04-29 09:22:09 +00:00
Jonas Ådahl
2c0c03ad27 shell: Handle empty comment gracefully
Parsing scripts using g_shell_parse_argv() line by line, it's useful to
have empty comments, so one can write pragraphs etc, e.g.

    # This is a comment with multiple paragraphs.
    #
    # It's useful to split things up like this at times.
    #
    # The empty comment characters makes it clear the paragraphs form a
    # single comment.
2025-04-29 00:29:20 +02:00
Philip Withnall
490438c416 Merge branch 'patch-pt' into 'main'
Update Portuguese translation

See merge request GNOME/glib!4609
2025-04-24 19:29:27 +00:00
Philip Withnall
585bdf45cf Merge branch 'uk_update1' into 'main'
Update Ukrainian translation

See merge request GNOME/glib!4610
2025-04-24 19:28:58 +00:00
Yuri Chornoivan
5e444e46bb Update Ukrainian translation 2025-04-24 17:37:13 +00:00
Hugo Carvalho
5624206212 Replace pt.po 2025-04-24 17:14:32 +00:00
Philip Withnall
35b47a5414 Merge branch 'preserve-mode' into 'main'
gfileutils: Preserve mode during atomic updates

Closes dconf#76

See merge request GNOME/glib!4607
2025-04-24 13:43:50 +00:00
Wesley Hershberger
45a36e52b5 gfileutils: Preserve mode during atomic updates
If g_file_set_contents{_full,} is replacing an existing file, require
that the tmpfile have the same mode as the existing file.

This prevents the umask from taking effect for consistent writes to
existing files.

Closes GNOME/dconf#76
2025-04-23 08:54:07 -05:00
Philip Withnall
0dbdce17dd tests: Fix some -Wsign-conversion warnings in GParamSpec tests
We can tighten up the types which are being used, to prevent the
warnings. Not everything in the world has to be a `guint`.

These warnings only showed up on the macOS CI runner.

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

Helps: #3405
2025-04-22 23:43:13 +01:00
Philip Withnall
0bf12ea619 gobject: Fix a few more straightforward -Wsign-conversion warnings
These only show up on macOS. Apparently it’s more sensitive to assigning
`gboolean` (which is secretly `int`) to a `guint` bitfield. 🤷

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

Helps: #3405
2025-04-22 23:12:56 +01:00
Philip Withnall
4e54b46ce9 gclosure: Fix two -Wsign-conversion warnings on macOS
These don’t show up for me on Linux, but are now causing CI failures on
macOS (https://gitlab.gnome.org/GNOME/glib/-/jobs/5006543):
```
../gobject/gclosure.c:923:40: error: implicit conversion changes signedness: 'gboolean' (aka 'int') to 'guint' (aka 'unsigned int') [-Werror,-Wsign-conversion]
      ATOMIC_SET (closure, in_marshal, in_marshal);
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-04-22 23:12:49 +01:00
Marco Trevisan
9f11c8962b Merge branch 'param-specs-constants' into 'main'
gparamspecs: Use standard min/max constants rather than literals

See merge request GNOME/glib!4605
2025-04-22 22:10:33 +00:00
Philip Withnall
a25e15695b Merge branch 'wsign-conversion3' into 'main'
Enable -Wsign-conversion for girepository, gthread, gmodule

See merge request GNOME/glib!4594
2025-04-22 21:47:03 +00:00
Philip Withnall
d425135164 gparamspecs: Use standard min/max constants rather than literals
This makes the code a little clearer. In most cases, it’s not a
functional change.

In a few cases, the values are different. I believe the original values
were incorrect (accidentally transposed, perhaps). This never caused an
issue because they were all immediately overwritten during construction
of a `GParamSpec`: these values were defaults in the `instance_init`
vfunc of the `GTypeInstance` for a `GParamSpec`, but the actual min/max
for the `GParamSpec` instance were immediately written over them in the
constructor (such as `g_param_spec_int()`).

Spotted in !4593.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-04-22 22:38:58 +01:00
Philip Withnall
988db0e89d Merge branch 'wsign-conversion2' into 'main'
Enable -Wsign-conversion for gobject directory

Closes #3405

See merge request GNOME/glib!4593
2025-04-22 21:31:41 +00:00
Philip Withnall
745d22eec8 Merge branch 'LLyaudet-main-patch-21388' into 'main'
docs: fix typo glong: ULONG_MAX -> LONG_MAX

See merge request GNOME/glib!4602
2025-04-22 17:00:38 +00:00
Laurent Lyaudet
2bf5064655 docs: add INT(16|32|64)_(MAX|MIN) and fix some typos 2025-04-22 17:00:38 +00:00
Sergey Bugaev
271ce5166b garray: Fix annotations
Notably without the (array), the argument of g_byte_array_append appears
as

  <type name="guint8" c:type="const guint8*"/>

which will cause the bindings to pass a byte, not a pointer.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2025-04-22 16:04:03 +03:00
Philip Withnall
be8c76c98c Merge branch 'networkmonitor-jail' into 'main'
Fix GNetworkMonitorNetlink operation under a FreeBSD jail with shared network stack

See merge request GNOME/glib!4603
2025-04-21 22:28:49 +00:00
Gleb Popov
b479d14371 Fix GNetworkMonitorNetlink operation under a FreeBSD jail with shared network stack 2025-04-21 22:28:49 +00:00
Philip Withnall
80e3ea1e1d Merge branch 'larma/cocoa-notification-bytes-icon' into 'main'
cocoa: add support for GBytesIcon in notification backend

See merge request GNOME/glib!4604
2025-04-21 21:39:33 +00:00
Marvin W
cf44fb0d2a cocoa: add support for GBytesIcon in notification backend 2025-04-18 14:36:34 +02:00
Thomas Haller
88f5db3e75 gobject/docs: remove wrong paragraph from GWeakRef docs
The "without first having or creating a strong reference" part is wrong.

While we invoke the dispose() method, we always still hold the last
reference. The calling thread called g_object_unref() with a strong
reference that we are about to give up, but at the point where we call
dispose(), we didn't yet decrement the ref count to zero. Doing so would
be a fatal bug.

As such, during dispose() the object is still healthy and still has a
strong pointer. You can call `g_weak_ref_set()` on that pointer without
taking an additional strong reference. Of course, if you don't actually
take a strong reference (and thus don't resurrect the object), then
right afterwards, the last reference is dropped to zero, and the
GWeakRef gets reset again.

But there is no need to claim that you need to take another strong
reference to set a GWeakRef during dispose(). This was always the case.

Also, reword the previous paragraph. I think this is clearer.
2025-04-17 18:07:27 +02:00
Michael Catanzaro
e237ec6c81 Merge branch 'get-binding-data-caller-allocates' into 'main'
gtlsconnection: Fix annotation

See merge request GNOME/glib!4598
2025-04-14 17:28:24 +00:00
Michael Catanzaro
ca99d65867 Merge branch 'contributing-tests' into 'main'
docs: Mention how to run the test suite in CONTRIBUTING.md

See merge request GNOME/glib!4596
2025-04-14 14:47:20 +00:00
Sergey Bugaev
6d3322e769 grefcount: Improve annotations
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2025-04-14 15:53:43 +03:00
Sergey Bugaev
b133c78c96 gbitlock: Mark pointer as (type gpointer)
For the same reasons as in the previous patch, pointer identity is
important for bit-locking.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2025-04-14 15:53:43 +03:00
Sergey Bugaev
66db12c411 gatomic: Mark pointer as (type gpointer)
Otherwise, it appears as an "in" parameter with
  <type name="gint" c:type="volatile gint*"/>
which is very confusing to the bindings.

An alternative would be to mark it as an "inout" integer, which matches
the semantics somewhat. However, that wouldn't quite capture the concept
of the value being modified having (pointer) identity, which is of
utmost importance for atomic operations. Hence, just say that we accept
a pointer to the value.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2025-04-14 15:53:43 +03:00
Sergey Bugaev
bf266f4116 gtlsconnection: Fix annotation
The array is allocated by the *caller*, not the callee, and then filled
by the callee during the call.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2025-04-14 15:32:18 +03:00
Philip Withnall
c077153699 docs: Mention how to run the test suite in CONTRIBUTING.md
We don’t want `CONTRIBUTING.md` to become an exhaustive manual of how to
contribute to what is a fairly standard C project using Meson, but it is
a fairly helpful hint to mention how to run the test suite. Then people
can use `meson test --help` and the Meson documentation to learn more.

Pointed out on !4589.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-04-12 18:32:09 +01:00
Philip Withnall
841b565b8d Merge branch 'fix-wrong-typelib-path' into 'main'
Windows: fix wrong typelib path

Closes #3657

See merge request GNOME/glib!4582
2025-04-12 15:45:52 +00:00
Dan Yeaw
5f12b1b400 Windows: fix wrong typelib path 2025-04-12 15:45:51 +00:00
Philip Withnall
ecc1f86e92 gmodule: Fix a minor -Wsign-conversion error on Windows
Spotted by CI: https://gitlab.gnome.org/pwithnall/glib/-/jobs/4968919

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

Helps: #3405
2025-04-12 16:25:03 +01:00
Philip Withnall
21d8e246e7 girepository: More minor -Wsign-conversion fixes from CI
These didn’t occur on my local machine, interestingly.

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

Helps: #3405
2025-04-12 16:24:32 +01:00
Philip Withnall
3de99090d0 girepository: Enable -Wsign-conversion for girepository subdirectory
As with previous commits, we’re enabling `-Wsign-conversion` piecemeal
for all of glib.git.

The previous few commits have fixed all the `-Wsign-conversion` warnings
in libgirepository, so let’s enable the warning by default for that
directory to prevent regressions.

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

Helps: #3405
2025-04-11 23:56:49 +01:00
Philip Withnall
7c06269eef girparser: Limit the size of GIR files which can be parsed
Due to passing around file lengths variously as `gsize` or `gssize`,
we can’t reliably handle files with length greater than `G_MAXSSIZE`, as
some of the APIs in use need `-1` to indicate that their input is nul
terminated.

Add some checks for this, and gracefully return an error if an input
file is too big, rather than just exploding.

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

Helps: #3405
2025-04-11 23:56:44 +01:00
Philip Withnall
4a29abe9f7 girparser: Stop setting blob length to -1 when no length is set
When parsing a GIR or building a typelib, stop setting the array length
field to `-1` as a default. That field is unsigned, so setting it to
`-1` is actually equivalent to setting it to `G_MAXUINT`. I can’t find
anywhere which treats `G_MAXUINT` or `-1` as a magic value there, so
it’s probably better off left unset.

Given the lack of documentation for the typelib code, though, there is a
fair chance I’m making a mistake and this is actually an integral part
of the format. Let’s see what breaks.

This fixes a `-Wsign-conversion` warning, at least.

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

Helps: #3405
2025-04-11 23:56:39 +01:00
Philip Withnall
debb6a9cc0 tests: Add a basic test for GIIrParser type parsing
This follows up from the previous two commits to add a unit test.

It doesn’t attempt to cover the multitude of other possible type parsing
conditions; at the moment it’s just a regression test for the previous
two commits, and somewhere to hang new tests on in future.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-04-11 23:56:35 +01:00
Philip Withnall
cff7783a32 girparser: Fix error handling for type parsing
Reworking the code to add proper `GError` handling for type parsing,
rather than the existing `g_critical()`, turned out to actually be
fairly straightforward.

So now `gi_ir_parser_parse_string()` returns
`G_MARKUP_ERROR_INVALID_CONTENT` on unparseable types, just like it does
with various other bits of invalid GIR.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-04-11 23:56:30 +01:00
Philip Withnall
e6d34fa5a8 girparser: Fix a potential buffer overflow with g_strndup()
If parsing a generic type which has no closing `>`, there was no check
that the `strchr()` call succeeded, which could have resulted in a
negative length being passed to `g_strndup()`, which would result in a
long positive length after implicit type casting.

Fix that by bringing an old error handling path back into use. This
results in a `g_critical()` in the calling function, which is good
enough for now. Potentially all this code could be reworked to use
`GError`, but that’s a much bigger project (a lot more of the
`girparser.c` code would need to change).

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

Helps: #3405
2025-04-11 23:56:26 +01:00
Philip Withnall
8ab78a66a4 girepository: Fix -Wsign-conversion warnings with string arithmetic
There are a few `g_strndup()` calls which use a length calculated from
the return value of `strchr()` minus the original string. That’s fine,
as long as `strchr()` doesn’t return `NULL`. Add some asserts to ensure
that.

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

Helps: #3405
2025-04-11 23:56:21 +01:00
Philip Withnall
f44511bc54 girepository: Fix straightforward -Wsign-conversion warnings
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3405
2025-04-11 23:56:17 +01:00
Philip Withnall
4b7f0a8f50 gthread: Enable -Wsign-conversion for gthread subdirectory
As with previous commits, we’re enabling `-Wsign-conversion` piecemeal
for all of glib.git.

It turns out that gthread didn’t have any `-Wsign-conversion` warnings
at all, so this was straightforward.

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

Helps: #3405
2025-04-11 23:56:12 +01:00
Philip Withnall
95fa8de2c3 gmodule: Enable -Wsign-conversion for gmodule subdirectory
There was only one `-Wsign-conversion` warning in the whole
subdirectory, so that was easy.

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

Helps: #3405
2025-04-11 23:56:08 +01:00
Philip Withnall
96178eb9c0 gobject: Fix a few more -Wsign-conversion warnings
These are all fairly straightforward, but I didn’t get them locally;
they only showed up on CI.

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

Helps: #3405
2025-04-11 23:48:23 +01:00