Commit Graph

30515 Commits

Author SHA1 Message Date
Philip Withnall
e7aa0039b9
gsocks5proxy: Rework functions to separate length and success/failure
The previous approach was to return a length as a `gssize`, with
negative values indicating failure. That works fine, but causes a lot of
signed/unsigned comparisons or assignments.

Tidy the code up by splitting success from length, returning success as
a boolean, and length as a `size_t*` out argument. This introduces no
functional changes, but does tidy the code up and fix some compiler
integer warnings.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-25 00:39:13 +01:00
Philip Withnall
6e362ce3b6
gio: Fix various implicit conversions from size_t to smaller types
Basically various trivial instances of the following MSVC compiler
warning:
```
../gio/gio-tool-set.c(50): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-25 00:37:47 +01:00
Michael Catanzaro
c378a5a049 Merge branch 'url-patch' into 'main'
gfileinfo: Fixed broken link to gio/file-attributes.html

See merge request GNOME/glib!4022
2024-04-23 21:50:20 +00:00
maxrdz
f0b4f50f66
gfileinfo: Fixed broken link to gio/file-attributes.html
Looks like the original author mixed up where the link label and the
link URL goes. :p

Previously the link would point to "https://docs.gtk.org/gio/file
attributes", with a space and no file extension.
2024-04-23 14:33:45 -07:00
Simon McVittie
26a3fb8518 gdbusconnection: Stop storing sender_unique_name in SignalData
This will become confusing when we start tracking the owner of a
well-known-name sender, and it's redundant anyway. Instead, track the
1 bit of data that we actually need: whether it's a well-known name.

Strictly speaking this too is redundant, because it's syntactically
derivable from the sender, but only via extra string operations.
A subsequent commit will add a data structure to keep track of the
owner of a well-known-name sender, at which point this boolean will
be replaced by the presence or absence of that data structure.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
7d21b719ed gdbusconnection: Factor out remove_signal_data_if_unused
No functional change, just removing some nesting. The check for whether
signal_data->subscribers is empty changes from a conditional that tests
whether it is into an early-return if it isn't.

A subsequent commit will add additional conditions that make us consider
a SignalData to be still in use and therefore not eligible to be removed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
5d7ad6897c gdbusconnection: Factor out add_signal_data()
No functional changes.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
816da60571 gdbusconnection: Factor out signal_data_new_take()
No functional changes, except that the implicit ownership-transfer
for the rule field becomes explicit (the local variable is set to NULL
afterwards).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
8dfea5609e gdbusconnection: Move SignalData, SignalSubscriber higher up
Subsequent changes will need to access these data structures from
on_worker_message_received(). No functional change here, only moving
code around.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
1e648b677f gdbusprivate: Add symbolic constants for the message bus itself
Using these is a bit more clearly correct than repeating them everywhere.
To avoid excessive diffstat in a branch for a bug fix, I'm not
immediately replacing all existing occurrences of the same literals with
these names.

The names of these constants are chosen to be consistent with libdbus,
despite using somewhat outdated terminology (D-Bus now uses the term
"well-known bus name" for what used to be called a service name,
reserving the word "service" to mean specifically the programs that
have .service files and participate in service activation).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:41:53 +01:00
Simon McVittie
fd265663f2 tests: Add test coverage for signals that match the message bus's name
This is a special case of unique names, even though it's syntactically
a well-known name.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:14:32 +01:00
Simon McVittie
984354e02d tests: Add a test-case for what happens if a unique name doesn't exist
On GNOME/glib#3268 there was some concern about whether this would
allow an attacker to send signals and have them be matched to a
GDBusProxy in this situation, but it seems that was a false alarm.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:14:32 +01:00
Simon McVittie
14c3d6938e tests: Add support for subscribing to signals from a well-known name
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:14:32 +01:00
Simon McVittie
124b4571bb tests: Add a data-driven test for signal subscriptions
This somewhat duplicates test_connection_signals(), but is easier to
extend to cover different scenarios.

Each scenario is tested three times: once with lower-level
GDBusConnection APIs, once with the higher-level GDBusProxy (which
cannot implement all of the subscription scenarios, so some message
counts are lower), and once with both (to check that delivery of the
same message to multiple destinations is handled appropriately).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:08:19 +01:00
Philip Withnall
954184211b Merge branch 'fix-gir-install' into 'main'
girepository/introspection: correctly install .gir files into custom locations

See merge request GNOME/glib!4020
2024-04-23 13:34:06 +00:00
Alexander Kanavin
22ec5a96e3 girepository/introspection: correctly install .gir files into custom locations
There is a meson option (gir_dir_prefix), but without being passed in here
the files would always get installed into the default location (datadir).

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
2024-04-23 14:21:21 +02:00
Philip Withnall
1cf9b36303 Merge branch 'wip/oholy/libmnt_monitor_fallback' into 'main'
gunixmounts: Use fallback if libmount monitoring fails

Closes tracker-miners#315

See merge request GNOME/glib!4019
2024-04-23 11:49:07 +00:00
Philip Withnall
21617108b3 Merge branch 'gunicode-fix' into 'main'
gunicode.h: fix warning with -Wcast-qual for define g_utf8_next_char()

See merge request GNOME/glib!4016
2024-04-23 11:45:52 +00:00
Ondrej Holy
dbb7a12a96 gunixmounts: Use fallback if libmount monitoring fails
The recently added libmount-based unix mount monitoring may fail when the
device exceeds inotify limits. Let's fallback to the older implementation
in case of the `mnt_monitor_get_fd` function failure. This among others
fixes tracker-miners failures caused by seccomp rules.

Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/315
2024-04-23 12:59:40 +02:00
Andika Triwidada
fddc8f4768 Update Indonesian translation 2024-04-22 11:05:44 +00:00
Andika Triwidada
ed958f7eb6 Update Indonesian translation
(cherry picked from commit 30ec6c8381)
2024-04-22 11:02:13 +00:00
Michael Catanzaro
34f9d71fca Merge branch 'ferdnyc-patch-1' into 'main'
docs(gio/overview): Restore missing heading

See merge request GNOME/glib!4017
2024-04-21 23:32:21 +00:00
FeRD (Frank Dana)
471bd469f1 docs(gio/overview): Restore missing heading 2024-04-21 23:03:54 +00:00
Hannes Müller
c583162cc6 gunicode.h: fix warning with -Wcast-qual for define g_utf8_next_char()
The define for g_utf8_next_char(p) includes a not needed final cast to
(char *). In fact, this cast has the adverse effect of causing a warning
if p is a (const char *) with gcc/clang compiler option -Wcast-qual.
So lets remove the not needed cast and add option -Werror=cast-qual
to glib/tests/utf8-pointer.c which uses g_utf8_next_char().
Now utf8-pointer.c compiles also with compiler option -Werror=cast-qual
and passes all tests.
2024-04-21 09:42:01 +02:00
Michael Catanzaro
81eaabb308 Merge branch 'completion-bins' into 'main'
completion: Invoke the command being completed

See merge request GNOME/glib!4013
2024-04-17 18:04:02 +00:00
Philip Withnall
70c0f3bff6
completion: Rework quoting in gsettings completion script
This is a partial revert and rework of commit
c79575362e, for the `gsettings` script
only (the other completion scripts are fine).

I blindly added quoting to everything shellcheck told me to, without
testing it properly.

As it turns out, the `$schemadir` argument to `gsettings` invocations
was deliberately not quoted, so that it would expand to zero arguments
if unset, and two arguments (`--schemadir /some/path`) if set earlier in
the command-being-completed.

Quoting it meant that it expanded to one argument (the empty string) if
unset, which caused the `gsettings` subcommands to fail, and hence any
further tab completion to fail.

Fix that as suggested on https://www.shellcheck.net/wiki/SC2086 by
turning `schemadir` into an array, which either has zero members if
unset, or two members if set.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-17 17:43:50 +01:00
Philip Withnall
295a6fb965
completion: Add missing copyright and licensing headers
The copyright entries come from looking at `git log gio/completion/*`
and, in particular, `git log -- gio/gsettings-bash-completion.sh` (etc.)
as the files were moved after being originally written, and haven’t
really changed since.

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

Helps: #1415
2024-04-17 17:43:44 +01:00
Philip Withnall
cc22637856
completion: Invoke the command being completed
As suggested by Ville Skyttä in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4012#note_2084405,
make sure to invoke the copy of the command which is being completed
when asking for completions of a given subcommand.

This avoids accidentally invoking any old `gdbus`/`gresource`/etc.
binary which is hanging around in another part of `$PATH`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-17 17:43:38 +01:00
Michael Catanzaro
2d85a8008d Merge branch 'bit-more-reuse' into 'main'
Add a few more missing license and copyright headers to files

See merge request GNOME/glib!4014
2024-04-17 15:20:24 +00:00
Philip Withnall
ba219db83b
tests: Update the reuse lint limits
More files now have their copyright and/or licensing tagged explicitly,
so let’s reduce the wiggle room for regressions.

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

See: #1415
2024-04-17 15:47:02 +01:00
Philip Withnall
8138246ab8
inotify: Add license and copyright headers to meson.build
The copyright from `git log gio/inotify/meson.build` is now included in
the file header. The following commits are too trivial to be
copyrightable:
 - d10be6102f
 - 03e86d000f
 - 1741fc2c6e
 - 8733d172a3

The file was contributed while the `COPYING` file for GLib was
LGPL-2.1-or-later, so was previously implicitly licensed as that.
Let’s make that explicit.

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

Helps: #1415
2024-04-17 15:46:23 +01:00
Philip Withnall
417f6a4bde
inotify: Trivially add SPDX-License-Identifier to inotify files
The license and copyright are already stated in human-readable form in
these files, so this should be uncontroversial.

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

Helps: #1415
2024-04-17 15:46:11 +01:00
Philip Withnall
34050a5c12
codegen: Add license and copyright headers to remaining files
The `.flake8` file has a trivial version history, so the copyright is
straightforward from that.

`meson.build` has a more complex history, but the only significant
contributions were from Centricular. From `git log
gio/gdbus-2.0/codegen/meson.build`, the other (following) commits are
too trivial to be copyrightable:
 - d10be6102f
 - 30b25a6fd9
 - 95fa229f34
 - 631c3534b7
 - 00d7568e4f
 - 9734e4854e
 - 65be80c3ed
 - 66e4ba806a
 - a1c78d63ef
 - a73ca336aa
 - 19353017a7
 - b4231844a2
 - 4cb945d780
 - 4ce58df854
 - e2433308c4
 - 013980d839

Both files were contributed while the `COPYING` file for GLib was
LGPL-2.1-or-later, so both were previously implicitly licensed as that.
Let’s make that explicit.

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

Helps: #1415
2024-04-17 15:33:24 +01:00
Philip Withnall
c8d199dc0d
reuse: License all .gitignore files as CC0-1.0 (public domain)
They’re all too trivial to actually have an enforceable copyright on.

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

Helps: #1415
2024-04-17 15:32:42 +01:00
Philip Withnall
68d8f721f3
codegen: Trivially add SPDX-License-Identifier to codegen Python files
The license and copyright are already stated in human-readable form in
these files, so this should be uncontroversial.

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

Helps: #1415
2024-04-17 15:31:50 +01:00
Philip Withnall
869ef92858 Merge branch 'shellcheck-completions' into 'main'
tests: Enable shellcheck for bash completion scripts

See merge request GNOME/glib!4012
2024-04-17 07:43:12 +00:00
Philip Withnall
b371f5b500 Merge branch 'wip/jtojnar/variant-docs' into 'main'
docs: Minor GVariant fixes

See merge request GNOME/glib!4011
2024-04-16 13:53:10 +00:00
Jan Tojnar
156e0c865a docs: Fix broken links
The file was renamed in 5d80471d4b.
2024-04-16 14:33:45 +01:00
Philip Withnall
e577f16d01
tests: Enable shellcheck for bash completion scripts
These were accidentally left off the list of files checked before,
because they don’t have `.sh` suffixes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:16:30 +01:00
Philip Withnall
827bca3212
completion: Ignore SC2207 for COMPREPLY assigments
Using the same justification as in
https://gitlab.gnome.org/GNOME/dconf/-/merge_requests/81#note_2083220:
it’s hard to get this right, with error handling, in a way which is
understandable to people reading it, and which both bash and shellcheck
will be happy with.

On the assumption that none of the completions generated by any of these
utilities will include ‘problematic’ characters (ones which would cause
word splitting or globbing in bash), just ignore the shellcheck
warnings. Note that I have not actually closely verified that these
utilities can’t return ‘problematic’ characters.

This means we can enable shellcheck, with fatal warnings, for these
scripts, and hence catch future regressions.

If someone wants to improve the handling of globbing/word splitting in
some/all of these array assignments in future, the shellcheck disables
can be removed.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:09:36 +01:00
Philip Withnall
6024fb9753
completion: Quote argument to unset
Otherwise it gets globbed and the wrong thing potentially gets unset.
Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:08:39 +01:00
Philip Withnall
17f0cad2c7
completion: Drop some unused variables
Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:08:08 +01:00
Philip Withnall
7ad93a0c95
completion: Use read -r rather then plain read
This means that backslashes in the input (which is unlikely, but I guess
possible) won’t affect line splitting. Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:07:12 +01:00
Philip Withnall
b1ef6a125e
completion: Quote variable dereferences within variable dereferences
Otherwise they could get split. Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:06:13 +01:00
Philip Withnall
d3d811f4e5
completion: Split declaration and assignment of variables
Having them on the same line masks failure of the subcommand generating
the value being assigned. Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:05:04 +01:00
Philip Withnall
a7ad2a4c3a
completion: Drop unnecessary $ from variables in arithmetic expressions
It’s not needed, according to shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:03:19 +01:00
Philip Withnall
c79575362e
completion: Add missing quoting
As suggested by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 13:58:49 +01:00
Philip Withnall
aaf715a046
completion: Stop using old backtick quoting for subcommands
Fixes a shellcheck warning.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 13:54:33 +01:00
Philip Withnall
f95e8b4e7c
completion: Add shellcheck shell hints to all completion scripts
Because completion scripts are not executed directly, they don’t have a
shebang line, so shellcheck can’t be sure which shell syntax to use for
them. Help it out.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 13:51:44 +01:00
Philip Withnall
efc85d1f49 Merge branch 'sa-onstack-unix-signals' into 'main'
gmain: Use alternate signal stack if the application provides one

Closes #3314

See merge request GNOME/glib!4010
2024-04-16 12:10:13 +00:00