Commit Graph

27028 Commits

Author SHA1 Message Date
Philip Withnall
ed8e86a7d4 gfileinfo: Add critical warnings for helper getters
As documented in a previous commit, these functions should not be called
without the right attributes being present in the `GFileInfo`. Add
critical warnings to make this more obvious.

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

Fixes: #2907
2023-02-08 11:58:15 +00:00
Philip Withnall
8cee721df8 gfileinfo: Remove erroneous GFileType casts from returns
Looks like copy/paste errors.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-08 10:00:43 +00:00
Philip Withnall
2f862993cc gfileinfo: Fix some minor documentation typos
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-08 09:57:51 +00:00
Philip Withnall
937c6f15cd gfileinfo: Document required attributes for helper getters
It doesn’t make sense to (for example) call `g_file_info_get_name()` if
the `GFileInfo` doesn’t contain `G_FILE_ATTRIBUTE_STANDARD_NAME`, given
that building the `GFileInfo` is typically a static process and entirely
under the control of the programmer.

By being this restrictive, we avoid having to return ‘unknown’ values
for some of these standard APIs, particularly the numeric ones such as
`g_file_info_get_size()`. If APIs like that were to work correctly in
the face of a `GFileInfo` without `G_FILE_ATTRIBUTE_STANDARD_SIZE`
specified, they’d have to be able to return a value to indicate the
attribute is missing. Returning `0` or `G_MAXSIZE` to indicate that
would be ambiguous.

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

Fixes: #2907
2023-02-08 09:54:54 +00:00
Marco Trevisan
5821425e11 Merge branch 'underspecified-dep' into 'main'
fix underspecified dependencies on generated headers

See merge request GNOME/glib!3260
2023-02-07 14:35:52 +00:00
Marco Trevisan
9201a20276 Merge branch 'th/no-mutex-in-g-print' into 'main'
gmessages: use g_atomic_pointer to access handlers for g_print()/g_printerr()

See merge request GNOME/glib!3259
2023-02-07 14:32:15 +00:00
Thomas Haller
4d7f66f214 gmessages: use g_atomic_pointer to access handlers for g_print()/g_printerr()
It seems unnecessary to use the mutex to get/set a single pointer.
2023-02-07 13:16:07 +01:00
Eli Schwartz
740440774a
fix underspecified dependencies on generated headers
Since gmodule-visibility.h is now a custom target and produced at
buildtime, it might not always exist in time for use in other source
files. This was the case for gio-inotify.

Add it as an additional source file to ensure in-time generation.
2023-02-06 23:00:04 -05:00
Philip Withnall
4177164fd2 Merge branch 'wip/pwithnall/revert-freebsd-ci' into 'main'
Revert "ci: Temporarily only run the FreeBSD 13 CI on a schedule"

See merge request GNOME/glib!3258
2023-02-06 16:52:11 +00:00
Philip Withnall
e6132f2322 Revert "ci: Temporarily only run the FreeBSD 13 CI on a schedule"
This reverts commit 163ebdc6c2.

The FreeBSD CI runner is back again.

See https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/601#note_1658477
2023-02-06 14:58:47 +00:00
Philip Withnall
6ba1627fe6 Merge branch 'g-atomic-array-alignment' into 'main'
GAtomicArray: Ensure metadata does not misalign the payload

See merge request GNOME/glib!3242
2023-02-06 14:08:06 +00:00
Philip Withnall
361745149f Merge branch 'msort-cheri' into 'main'
Allow using msort_r CHERI-enabled architectures

See merge request GNOME/glib!3243
2023-02-06 14:04:18 +00:00
Philip Withnall
bd8b756853 Merge branch 'gtype-use-sized-free' into 'main'
Revert "gtype: Use the system allocator on UNIX" and use g_free_sized instead

See merge request GNOME/glib!3251
2023-02-06 14:00:38 +00:00
Marco Trevisan
5c34cf3dbb Merge branch 'ebassi/no-preallocs' into 'main'
Remove n_preallocs field from InstanceData

See merge request GNOME/glib!3256
2023-02-06 13:33:16 +00:00
Emmanuele Bassi
8f92f742b9 Remove n_preallocs field from InstanceData
The GTypeInfo.n_preallocs field has been ignored since GLib 2.10, but it
hasn't been removed from the internal instance data representation.
2023-02-04 16:55:30 +01:00
Michael Catanzaro
35170735de Merge branch 'force-non-null-gslice-free' into 'main'
gslice: Do not try to memset-0 NULL a pointer

Closes #2908

See merge request GNOME/glib!3253
2023-02-03 23:19:43 +00:00
Marco Trevisan (Treviño)
893b86b939 gslice: Mark memory arguments and return values as nullable when it's the case
GSlice can handle NULL arguments or return NULL values, but we did not
properly mark them all the times.
2023-02-03 16:28:51 +01:00
Marco Trevisan (Treviño)
6af6f3eb9b gslice: Do not try to memset-0 NULL a pointer
According to the docs, g_slice_free1() is supposed to do nothing if
@mem_block is NULL, but we still try to zero it in case we're using
g_mem_gc_friendly.

So avoid this case.

Closes: #2908
2023-02-03 16:28:37 +01:00
Marco Trevisan (Treviño)
69e9ba80e2 gtype: Use g_malloc0 and g_free_sized to allocate and free memory
We've a sized free now, so we can just use it!
2023-02-03 11:38:00 +01:00
Marco Trevisan (Treviño)
ce1cba0884 Revert "gtype: Use the system allocator on UNIX"
Since commit 45b5a6c0 GSlice is just a wrapper to g_malloc0/g_free, so
there's no point to use a different implementation for UNIXes vs
windows.

This reverts commit 3b7af4dd5d.
2023-02-03 11:38:00 +01:00
Marco Trevisan
95cbff0fd2 Merge branch 'free-sized' into 'main'
gmem: Add g_free_sized() and g_aligned_free_sized()

See merge request GNOME/glib!3231
2023-02-03 10:01:35 +00:00
Philip Withnall
548d917f35 Merge branch 'gcc13-warning-fix' into 'main'
timezone: Fix a compiler warning

See merge request GNOME/glib!3248
2023-02-03 08:02:57 +00:00
Philip Withnall
b3b459107a Merge branch 'fix-inline-warnings' into 'main'
gstring: Avoid warnings from inline functions

See merge request GNOME/glib!3249
2023-02-03 07:57:40 +00:00
Matthias Clasen
d9f8d73be2 gstring: Avoid warnings from inline functions
The current code for g_string_append_c_inline generates
warnings when used, with -Wnull-dereference. Avoid that.
2023-02-03 00:36:53 +00:00
Matthias Clasen
cbb2ca8c4a timezone: Fix a compiler warning
gcc 13 complains that last_explicit_transition_time
may be used uninitialized.
2023-02-03 00:36:21 +00:00
Philip Withnall
964ecf5ec9 Merge branch 'wip/pwithnall/freebsd-ci-again' into 'main'
ci: Temporarily only run the FreeBSD 13 CI on a schedule

See merge request GNOME/glib!3250
2023-02-03 00:30:14 +00:00
Philip Withnall
163ebdc6c2 ci: Temporarily only run the FreeBSD 13 CI on a schedule
Rather than on every commit, because the CI runner is currently broken:
https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/601.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-03 00:13:53 +00:00
Philip Withnall
622e1d8c83 Merge branch 'wip/ernestask/converter-null-out' into 'main'
gio: converter: Forbid null out arguments

See merge request GNOME/glib!3245
2023-02-02 22:39:57 +00:00
Ernestas Kulik
e0976efee9 gio: converter: Forbid null out arguments
Currently, inbuf_size and outbuf_size are not documented as not
nullable, but they are expected to be so, which might lead to unexpected
crashes. Moreover, outbuf itself is also expected to not be null, so
this commit adds the appropriate GI annotations and early returns on
failed preconditions.
2023-02-02 21:25:56 +02:00
Ekaterine Papava
f6c6171c08 Update Georgian translation 2023-02-02 18:55:40 +00:00
Philip Withnall
97ebd794a7 gslice: Use g_free_sized() instead of g_free()
If libc supports `free_sized()`, this could mean that freeing slices is
a bit more performant. If not, it falls back to using `free()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-02 12:30:59 +00:00
Philip Withnall
329843f682 gmem: Add g_free_sized() and g_aligned_free_sized()
These wrap `free_sized()` and `free_aligned_sized()`, which are present
in C23[1]. This means that user code can start to use them without checking
for C23 support everywhere first.

It also means we can use them internally in GSlice to get a bit of
performance for the code which still uses it.

See https://en.cppreference.com/w/c/memory/free_aligned_sized and
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2699.htm.

[1]: Specifically, section 7.24.3.4 of the latest C23 draft at
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3088.pdf.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-02 12:30:59 +00:00
Fran Dieguez
c88e9e1f5c Update Galician translation 2023-02-01 21:46:54 +00:00
Marco Trevisan
fe2de360de Merge branch 'cxx-leak' into 'main'
tests: Fix a minor leak in the cxx string append tests

See merge request GNOME/glib!3247
2023-02-01 16:29:04 +00:00
Marco Trevisan
155e44652e Merge branch 'gstring-free-warning' into 'main'
Make g_string_free (_, FALSE) warn on unused result

See merge request GNOME/glib!3226
2023-02-01 16:28:02 +00:00
Marco Trevisan
151ca8d28d Merge branch 'gdbus-test-leak' into 'main'
tests: Fix a few minor leaks in gdbus-example-peer

See merge request GNOME/glib!3246
2023-02-01 16:24:57 +00:00
Kukuh Syafaat
76639a3620 Update Indonesian translation 2023-02-01 02:44:58 +00:00
Philip Withnall
b3389b66d6 tests: Fix a minor leak in the cxx string append tests
See https://gitlab.gnome.org/GNOME/glib/-/jobs/2547640

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

Helps: #2904
2023-01-31 11:52:11 +00:00
Philip Withnall
bd5e57ef17 tests: Fix a few minor leaks in gdbus-example-peer
One leak spotted by the Coverity, the others found via valgrind.

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

Coverity CID: #1504322
2023-01-31 11:44:44 +00:00
Aleksandr Melman
f499e37979 Update Russian translation 2023-01-29 22:11:03 +00:00
Alex Richardson
d2bbd69fd5 Allow using msort_r CHERI-enabled architectures
If we are sorting something that is a multiple of sizeof(void*), we have
to ensure that we swap one pointer at a time since swapping using
sub-pointer-size stores invalidate the pointers (pointers have a hidden
validity tags that is invalidated when performing non-monotonic
operations such as storing only part of the pointers).

While touching this code also use G_ALIGNOF() instead of a macro that
is generated at configure time.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-01-29 12:40:26 +00:00
Alex Richardson
a03950b43c GAtomicArray: Ensure metadata does not misalign the payload
We have to ensure that the memory location is sufficiently aligned to
store any object. This unbreaks the code for CHERI where using gsize
results in values that are only aligned to 8 bytes, but we need 16 byte
alignment for pointers. This is fully API/ABI compatible since amount
of padding before the actual allocation does not change for existing
architectures, only for CHERI.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-01-29 12:36:06 +00:00
Alex Richardson
c434743111 Fix build of gio/ttests/est_resources2.o with LLVM objcopy
LLVM objcopy's --strip-all is more aggressive that GNU objcopy --strip-all
and will remove everything that is not actually used. In this case we
see the following error:
`error: 'gio/tests/test_resources.o': Symbol table has link index of 5 which is not a valid index`

Fix this by only removing debug symbols instead of all unused symbols and
sections.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2720
2023-01-28 10:46:50 +00:00
Alex Richardson
6d93568e36 Fix building gio/tests/test_resources.o with LLVM ld
Unlike GNU ld which has a default target architecture, ld.lld is always a
cross-linker and has the same behaviour for all targets. If you don't tell
ld.lld what the target architecture is it can't infer the right ELF flags
for the resulting object file.
```
$ ~/cheri/output/sdk/bin/ld -r -b binary gio/tests/test5.gresource -o gio/tests/test_resources.o -v
LLD 14.0.0 (compatible with GNU linkers)
ld: error: target emulation unknown: -m or at least one .o file required
```

As you can see from the error message it can't infer the target
architecture (you need a least one valid .o file or the -m flag).
If you use the compiler instead of directly invoking the linker it will
pass the appropriate flags:
```
$ ~/cheri/output/sdk/bin/clang -r -Wl,-b,binary gio/tests/test5.gresource -o gio/tests/test_resources.o -v
clang version 14.0.0 (https://github.com/CTSRD-CHERI/llvm-project.git ff66b683475fc44355b2010dbcbe1202d785e6f8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/alexrichardson/cheri/output/sdk/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/home/alexrichardson/cheri/output/sdk/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o gio/tests/test_resources.o -L/usr/lib/gcc/x86_64-linux-gnu/12 -L/usr/lib/gcc/x86_64-linux-gnu/12/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/home/alexrichardson/cheri/output/sdk/bin/../lib -L/lib -L/usr/lib -r -b binary gio/tests/test5.gresource
❯ file gio/tests/test_resources.o
gio/tests/test_resources.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
```

This works for most architectures, but ones that need additional metadata
sections to encode the used ABI, etc. will require a different approach
using .incbin. However, that is a change for another MR.

Partially fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2720
2023-01-28 10:46:50 +00:00
Yuri Chornoivan
eafd19da29 Update Ukrainian translation 2023-01-27 20:47:17 +00:00
Marco Trevisan
183c646fea Merge branch 'gmain-cleanups' into 'main'
GMainContext: Use nullable context in docs (and in some missing code)

See merge request GNOME/glib!3234
2023-01-27 14:03:13 +00:00
Philip Withnall
0bf7e8a1f4 Merge branch 'issue-2898-g_print_encoding' into 'main'
Document g_print and g_printerr encoding behaviour

Closes #2898

See merge request GNOME/glib!3233
2023-01-27 14:01:59 +00:00
Daniel Carpenter
04879542a4 Document g_print and g_printerr encoding behaviour 2023-01-27 14:01:58 +00:00
Sergey Bugaev
c121118bc4 tests: Silence a warning
In case the OS does not support epoll and kqueue, we get the warning:

gio/tests/pollable.c: In function ‘test_pollable_unix_nulldev’:
gio/tests/pollable.c:266:7: warning: unused variable ‘fd’
[-Wunused-variable]
  266 |   int fd;

Get rid of it.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-01-27 11:58:56 +03:00
Sergey Bugaev
718f05d090 gwakeup: #include <stdint.h>
Since commit 94b658ab4c, gwakeup.c has
started using C99 integer types, but has not included <stdint.h>. This
broke building on GNU/Hurd. Fix this by adding the missing include.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-01-27 11:58:56 +03:00