summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'wip/smcv/steal-fd' into 'master'HEADmasterWill Thompson2023-02-276-15/+62
|\ | | | | | | | | backports: Add g_steal_fd, from GLib >= 2.70 See merge request GNOME/libglnx!47
| * backports: Add g_steal_fd, from GLib >= 2.70Simon McVittie2022-11-086-15/+62
|/ | | | | | | | | | This is essentially the same as glnx_steal_fd, so make glnx_steal_fd an alias for it. The unit test is taken from GLib, slightly modified to avoid g_close() and also test the old name glnx_steal_fd(). Signed-off-by: Simon McVittie <smcv@collabora.com>
* Merge branch 'wip/smcv/memdup2' into 'master'Colin Walters2022-11-014-5/+82
|\ | | | | | | | | backports: Add a backport of g_memdup2() See merge request GNOME/libglnx!46
| * tests: Add a simple test for g_memdup2, from GLibSimon McVittie2022-10-283-0/+53
| | | | | | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
| * backports: Add a backport of g_memdup2()Simon McVittie2022-10-281-5/+29
|/ | | | | | | | | | | | g_memdup2() replaces g_memdup(), which is prone to integer overflow on 64-bit systems if copying a very large object with an attacker-controlled size. The original version in GLib is extern, but it seems simple enough to inline a backport. Related: https://gitlab.gnome.org/GNOME/glib/-/issues/2319 Signed-off-by: Simon McVittie <smcv@collabora.com>
* Merge branch 'wip/smcv/assert-true-false' into 'master'Simon McVittie2022-10-103-0/+26
|\ | | | | | | | | backport-testutils: Add g_assert_true(), g_assert_false() See merge request GNOME/libglnx!44
| * backport-testutils: Add g_assert_true(), g_assert_false()Simon McVittie2022-10-103-0/+26
| | | | | | | | | | | | | | | | These were only added in 2.38, and some projects with particularly ancient dependencies (like the Steam Runtime, based on a 2012 version of Ubuntu) still avoid depending on that version. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | Merge branch 'wip/smcv/strtok-r' into 'master'Will Thompson2022-10-101-3/+9
|\ \ | |/ |/| | | | | tests: Ensure saveptr is NULL before first call to strtok_r() See merge request GNOME/libglnx!45
| * tests: Ensure saveptr is NULL before first call to strtok_r()Simon McVittie2022-10-101-3/+9
|/ | | | | | | | | The standards-conformant behaviour is that the contents of saveptr are ignored when the first argument is non-NULL, but the man page notes that some older implementations required saveptr to be NULL in that situation, and the gcc 4.8 provided by the Steam Runtime warns about this. Signed-off-by: Simon McVittie <smcv@collabora.com>
* Merge branch 'wip/smcv/warnings' into 'master'Will Thompson2022-10-103-2/+46
|\ | | | | | | | | build: Explicitly disable warnings for non-ISO C features See merge request GNOME/libglnx!42
| * build: Explicitly disable warnings for non-ISO C featuresSimon McVittie2022-10-103-2/+46
| | | | | | | | | | | | | | | | | | | | | | | | libglnx is intentionally not portable to non-Unix platforms or to compilers that do not implement gcc/clang extensions, so it's counterproductive to warn about these extensions, even if libglnx is used by a parent project that generally (for the parts that don't use libglnx) wants to be portable to any ISO C compiler. Suggested by Will Thompson on !36. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | Merge branch 'wip/smcv/2-74-constants' into 'master'Simon McVittie2022-10-101-0/+13
|\ \ | | | | | | | | | | | | backports: Backport new NONE/DEFAULT constants from GLib 2.74 See merge request GNOME/libglnx!39
| * | backports: Backport new NONE/DEFAULT constants from GLib 2.74Simon McVittie2022-10-101-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These enums were not originally defined with a zero-valued constant (or in the case of GApplicationFlags, the constant always existed but its name was inappropriate for GObject-Introspection), and the corresponding constants were added in GLib 2.74 to make them more self-documenting. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | | Merge branch 'wip/smcv/null-option-entry-ifndef' into 'master'Simon McVittie2022-10-101-1/+1
|\ \ \ | |/ / |/| | | | | | | | backports: Use #ifndef instead of GLIB_CHECK_VERSION See merge request GNOME/libglnx!43
| * | backports: Use #ifndef instead of GLIB_CHECK_VERSIONSimon McVittie2022-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | As Will Thompson pointed out on !37, G_OPTION_ENTRY_NULL is a macro in GLib, so we can test for it with `#ifndef` rather than a version guard. This is a little bit nicer for parent projects that might already have their own backport of it. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | | Merge branch 'wip/smcv/testing-helpers' into 'master'Simon McVittie2022-10-1010-12/+1050
|\ \ \ | |/ / |/| | | | | | | | Backport g_test_skip_printf(), etc. See merge request GNOME/libglnx!38
| * | Backport most of the test convenience helpers from GLib's GTestSimon McVittie2022-08-198-2/+1007
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes a test (who tests the tests themselves?). Run as `${build}/tests/testing --tap` with semi-modern GLib, or `${build}/tests/testing --verbose` with GLib < 2.38, to check that the output is as reasonable as possible given the limitations of the GLib version in use. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * | Move assertion/test utilities to a separate headerSimon McVittie2022-08-195-12/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A lot of recent convenience APIs can easily be backported, but they'll clutter glnx-backports.h. In preparation, split these out. Another reason to separate these is that when we start adding backports of test utilities that need implementation code in the libglnx static library, we'll want their implementations to be in a separate translation unit, so that they don't get linked into production executables, only into tests. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * | testlib: Be compatible with ancient GLib by using glnx_close_fdSimon McVittie2022-08-191-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | This is an enabler for testing a backport of GTest helpers (g_test_skip(), etc.) in the oldest environment that I have conveniently available (Steam Runtime 1 'scout' with GLib 2.32). Signed-off-by: Simon McVittie <smcv@collabora.com>
* | | Merge branch 'wip/smcv/g-info' into 'master'Simon McVittie2022-10-102-0/+12
|\ \ \ | | | | | | | | | | | | | | | | backports: Backport g_info() See merge request GNOME/libglnx!40
| * | | backports: Backport g_info()Simon McVittie2022-07-272-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The rest of the g_log() wrappers have been there since time immemorial, but g_info() was initially omitted. It's useful for projects like Flatpak that want to have two levels of off-by-default logging, which map nicely to info and debug. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | | | Merge branch 'wip/smcv/easy-constants' into 'master'Simon McVittie2022-10-101-0/+20
|\ \ \ \ | | |/ / | |/| / | |_|/ |/| | Add backports of straightforward constants See merge request GNOME/libglnx!37
| * | backports: Backport G_DBUS_METHOD_INVOCATION_HANDLED, _UNHANDLEDSimon McVittie2022-08-191-0/+8
| | | | | | | | | | | | | | | | | | | | | These are convenient for the same reasons as G_SOURCE_REMOVE and G_SOURCE_CONTINUE. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * | backports: Backport G_OPTION_FLAG_NONE, G_OPTION_ENTRY_NULLSimon McVittie2022-08-191-0/+8
| | | | | | | | | | | | | | | | | | These make tables of options a bit clearer to write. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * | backports: Backport G_SPAWN_DEFAULTSimon McVittie2022-08-191-0/+4
| | | | | | | | | | | | | | | | | | This makes the absence of flags a bit clearer to write. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | | Merge branch 'wip/smcv/warnings' into 'master'Simon McVittie2022-10-101-1/+1
|\ \ \ | |/ / |/| | | | | | | | build: Reduce default warning level from 3 to 2 See merge request GNOME/libglnx!36
| * | build: Reduce default warning level from 3 to 2Simon McVittie2022-07-271-1/+1
| |/ | | | | | | | | | | | | | | Warning level 2 is -Wall -Wextra, and warning level 3 adds -Wpedantic (warnings about use of non-ISO extensions). libglnx is intentionally using non-ISO features, so -Wpedantic is counterproductive. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | Merge branch 'pr/ficlone-fixes' into 'master'Colin Walters2022-08-011-2/+13
|\ \ | |/ |/| | | | | fdio: fix fd offset handling with `FICLONE` See merge request GNOME/libglnx!41
| * fdio: fix fd offset handling with `FICLONE`Jonathan Lebon2022-07-291-2/+13
|/ | | | | | | | | | | | | | | | | | | | | | | | When using `FICLONE`, the kernel does a full file clone and disregards the fd offsets. Users of this API however assume that it *is* offset-sensitive. So we need to verify that the fd offsets are at the start of the files before we call `FICLONE`. This was done in systemd also in: https://github.com/systemd/systemd/commit/c622fbdb8d37 The commit message does not explain this but `ioctl_ficlone(2)` says: The `FICLONE` ioctl clones entire files. (Compare with `FICLONERANGE`, which takes a struct with offsets and the length). Similarly, we need to seek to the end of the file descriptors on success so that we're consistent with the behaviour of the other backends available (`copy_file_range`, `sendfile` and manual copying). This also matches what systemd does nowadays: https://github.com/systemd/systemd/blob/80f967311ac5/src/shared/copy.c#L199
* Merge branch 'wip/smcv/warnings' into 'master'Phaedrus Leeds2022-05-105-10/+11
|\ | | | | | | | | Fix and enable more compiler warnings See merge request GNOME/libglnx!35
| * meson: Build with more warnings by defaultSimon McVittie2022-04-241-0/+1
| | | | | | | | | | | | | | | | If we keep this module closer to warnings-clean, then it can be submoduled into Meson projects that enable warnings by default without having to override it to a lower warning-level. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * tests: Make signedness of timestamp agreeSimon McVittie2022-04-241-1/+1
| | | | | | | | | | | | | | This silences a warning from gcc -Wsign-compare. g_get_monotonic_time() returns a signed int64. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * tests: Make iterator signedness agree with limitSimon McVittie2022-04-241-1/+1
| | | | | | | | | | | | | | | | | | g_variant_n_children() returns a size_t (or gsize, which is equivalent) so in principle it could overflow an int, although in practice we are not going to have that many extended attributes. This silences a warning from gcc -Wsign-compare. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * fdio: Match signedness of length parameterSimon McVittie2022-04-241-1/+1
| | | | | | | | | | | | | | | | This is documented as taking a length of -1, but the parameter is unsigned, so it's more correctly ((gsize) -1). This silences a warning from gcc -Wsign-compare. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * fdio: Make signedness of iterator consistent with limitSimon McVittie2022-04-241-1/+1
| | | | | | | | | | | | | | gcc -Wsign-compare warns about this. The iteration limit is constant and small enough that either int or guint would be fine. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * fdio, xattrs: Mark unused cancellables as suchSimon McVittie2022-04-242-5/+5
| | | | | | | | | | | | | | These functions take a GCancellable for consistency with other file APIs, but are not actually cancellable at the moment. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * console: Mark an unused parameter as suchSimon McVittie2022-04-241-1/+1
| | | | | | | | | | | | | | This signal handler is only called for SIGWINCH, so it doesn't need to look at its parameter. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | Merge branch 'wip/smcv/subproject' into 'master'Phaedrus Leeds2022-05-1012-26/+148
|\ \ | |/ |/| | | | | Improve Meson subproject support See merge request GNOME/libglnx!34
| * fdio: Skip glnx_try_fallocate() if _GNU_SOURCE is not definedSimon McVittie2022-04-212-1/+2
| | | | | | | | | | | | | | | | | | fallocate() is only visible in fcntl.h if _GNU_SOURCE is defined. Most users of libglnx will want to do that anyway, but it seems nicer to avoid "implicit declaration of function ‘fallocate’" warnings from simply including <libglnx.h> into naive code. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * tests: Verify libglnx can work as a subprojectSimon McVittie2022-04-218-5/+95
| | | | | | | | | | | | | | What isn't tested usually doesn't work, and the only way to use libglnx is as a subproject, so test it like that. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * tests: Optionally skip building and running the actual testsSimon McVittie2022-04-212-20/+31
| | | | | | | | | | | | | | If we're building libglnx as a subproject in a larger project, we won't necessarily want to run these. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * tests: Build libglnx-testlib as a separate static librarySimon McVittie2022-04-211-2/+20
| | | | | | | | | | | | | | | | One of Flatpak's unit tests uses this, for _GLNX_TEST_SCOPED_TEMP_DIR. Its API is not really stable, but libglnx is a "copylib" anyway, so none of it has (or needs) a strictly stable API. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * meson: Always build with hidden symbol visibilitySimon McVittie2022-04-211-0/+1
| | | | | | | | | | | | | | | | | | This copylib isn't intended to be part of anyone's ABI. In Autotools, this is typically implemented by doing some ad-hoc compiler checks and adding -fvisibility=hidden to the global CFLAGS of any library that pulls in libglnx, but in Meson it's a build system feature. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * meson: Automatically link libglnx-dependent objects to gio-unixSimon McVittie2022-04-211-0/+1
|/ | | | | | | | | If we don't do this, users of libglnx all have to add this dependency themselves, otherwise they'll get errors like: fatal error: gio/gfiledescriptorbased.h: No such file or directory Signed-off-by: Simon McVittie <smcv@collabora.com>
* Merge branch 'mwleeds/fix-config-h-clean' into 'master'Simon McVittie2022-03-011-0/+1
|\ | | | | | | | | Add libglnx-config.h to CLEANFILES See merge request GNOME/libglnx!33
| * Add libglnx-config.h to CLEANFILESPhaedrus Leeds2022-03-011-0/+1
|/ | | | | This fixes make distcheck for Flatpak (but you have to re-run autogen.sh).
* Merge branch 'wip/noxattr' into 'master'Colin Walters2022-02-221-1/+3
|\ | | | | | | | | tests: Don't copy extended attributes when testing pseudo-files See merge request GNOME/libglnx!32
| * tests: Don't copy extended attributes when testing pseudo-filesSimon McVittie2022-02-221-1/+3
|/ | | | | | | It seems that on SELinux systems, files in /proc have extended attributes that cannot be copied by an unprivileged user. Signed-off-by: Simon McVittie <smcv@debian.org>
* Merge branch 'wip/reuse' into 'master'Simon McVittie2022-02-1942-503/+750
|\ | | | | | | | | Declare copyright and licensing using REUSE See merge request GNOME/libglnx!27
| * Update copyright holder for Endless' contributionsSimon McVittie2022-02-196-6/+6
| | | | | | | | | | | | | | Will Thompson reports that all of Endless' IP was transferred to Endless OS Foundation LLC. Signed-off-by: Simon McVittie <smcv@debian.org>