Commit Graph

30172 Commits

Author SHA1 Message Date
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
Marco Trevisan (Treviño)
3d474bd8c1 unix: Prevent compiler optimization to ignore our memset to zero
It's well known that memset may be optimized out by compilers and this
is one of these cases that freebsd CI highlighted.

To prevent this to happen we should use memset_explicit() but that's C23, so
till we don't support that, let's re-implement that ourself
making the compiler not to optimize our memset's.

In theory we could just rely on C11's memset_s, but that's not working
either in freebsd.
2024-04-16 13:49:46 +02:00
John Ralls
035c318324 glib/tests/unix: Disable the alternate signal stack using SS_DISABLE
In other unix implementations other than linux, sigaltstack can't use a
NULL pointer for old_stack, so let's use SS_DISABLE instead to disable
the alternate stack.

Co-Authored-By: Marco Trevisan <mail@3v1n0.net>
2024-04-16 13:49:44 +02:00
Michael Catanzaro
5c8fbc3cda Merge branch 'scan-build' into 'main'
Fix various bugs found by scan-build and refresh scan-build config in CI

See merge request GNOME/glib!4005
2024-04-15 15:47:45 +00:00
Michael Catanzaro
e831627881 Merge branch '3310-subprocess-sigpipe' into 'main'
gsubprocess: Globally ignore SIGPIPE

Closes #3310

See merge request GNOME/glib!3991
2024-04-15 15:33:00 +00:00
Emmanuele Bassi
ac77a3b09f Merge branch 'coc' into 'main'
docs: Update Code of Conduct URI

See merge request GNOME/glib!4008
2024-04-15 15:12:58 +00:00
John Ralls
8c842792a9 glib/tests/unix: Only check for SA_NOCLDSTOP on SIGCHLD 2024-04-15 17:12:28 +02:00
Marco Trevisan (Treviño)
137db219a7 gmain: Use alternate signal stack if the application provides one
Some applications, toolkits or languages may define an alternative stack
to use for traces. This is for example the case of go.

So, in case an application defines an alternate signal stack, GLib should
use that instead of the default one to receive signals otherwise it may
break the application expectations and write where it's not allowed to.
2024-04-15 17:06:05 +02:00
Philip Withnall
57343f48ff
docs: Update Code of Conduct URI
It’s the same document, just in a different place.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 20:36:29 +01:00
Philip Withnall
c844abc759
ci: Force-enable -Dglib_debug for scan-build jobs
Several of the assertions in GLib (particularly on hot paths in
`gobject.c`) are protected behind `#if G_ENABLE_DEBUG`. In order for
scan-build to see them, the scan-build CI job needs to make sure that
a debug build is definitely enabled — not just rely on it being
implicitly enabled via the combination of other build options.

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

Helps: #1767
2024-04-12 19:35:05 +01:00
Philip Withnall
0814be8bef
gvariant-serialiser: Check offsets array is initialised before using it
When piecewise validating the offset table for a variable sized array,
it’s possible that the offset table (`offsets.array`) won’t actually
have been set by `gvs_variable_sized_array_get_frame_offsets()` iff the
serialised `GVariant` is not in normal form.

Add an additional check to guard against this. This will result in an
empty child variant being returned, as with other error handling paths
in `gvs_variable_sized_array_get_child()`.

This is a true positive spotted by scan-build. Thanks, scan-build.

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

Helps: #1767
2024-04-12 19:27:34 +01:00
Philip Withnall
4b7f6ffe4c
gparamspecs: Fix NULL pointer dereference
I’m not sure exactly how this code is supposed to work, so this might
not be the right fix. But there’s definitely a problem here, and it was
spotted by scan-build.

If `param_value_array_validate()` is entered with
`value->data[0].v_pointer == NULL && aspec->fixed_n_elements`, that `NULL`
will be stored in `value_array` too. `value->data[0].v_pointer` will
then be set to a new non-`NULL` array.

A few lines down, `value_array_ensure_size()` is called on
`value_array` – which is still `NULL` – and this results in a `NULL`
pointer dereference.

It looks like `value->data[0].v_pointer` and `value_array` are used
interchangeably throughout the whole of the function, so assign the new
value of `value->data[0].v_pointer` to `value_array` too.

My guess is that `value_array` is just a convenience alias for
`value->data[0].v_pointer`, because the latter is a real mouthful to
type or read.

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

Helps: #1767
2024-04-12 18:46:13 +01:00
Philip Withnall
96552fc904
gspawn: Fix use of uninitialised FDs on error path
Spotted by scan-build, an actual true positive result from it, and a
fiendish one too.

If any of the calls to `dupfd_cloexec()` (except the final one) fail,
the remainder of the `duped_source_fds` array would have been left
uninitialised.

The code in `out_close_fds` would have then called `g_clear_fd()` on an
uninitialised FD, with unpredictable results.

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

Helps: #1767
2024-04-12 18:46:07 +01:00
Philip Withnall
3c6c60611f
girnode: Simplify NULL node handling
All of the indications in the surrounding code are that `node` should
never be `NULL`, but the error handling for it did actually allow it to
be `NULL` iff its `parent` was also `NULL`.

That made scan-build (kind of legitimately) warn about `NULL` pointer
dereferences of `node`.

Avoid that by unambiguously using an assertion to prevent `NULL` nodes.

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

Helps: #1767
2024-04-12 18:45:59 +01:00
Philip Withnall
ad0532f2bf
xdgmimeglob: Fix a memory leak on a duplicate-entry path
Rather than `strdup()`ing strings when passing them into
`_xdg_glob_list_append()`, `strdup()` them *inside* the function
instead.

This avoids a leak in the case that the list entry (tuple of `data` and
`mime_type`) already exists in the list.

This has been upstreamed as
https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/36.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 18:45:52 +01:00
Philip Withnall
ae3bd19108
gresource: Improve resource unregistration performance slightly
Rather than iterating over the list twice: once to find the resource,
and once to re-find its link and delete it, just use
`g_list_delete_link()` to delete what was found.

This has the lovely side-effect of squashing a false positive from
scan-build, which thought there was a use-after-free of `resource` in
the caller, due to `g_resource_unref()` being called on it here.

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

Helps: #1767
2024-04-12 18:45:46 +01:00
Philip Withnall
1ed199a881
tests: Use g_assert_*() rather than g_assert() in gdbus-export tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 18:45:39 +01:00
Philip Withnall
3f30ec86cd
gdbusconnection: Fix user_data leaks on error
There were a couple of functions in `GDBusConnection` which take a
`user_data` argument, but which then leak it if they error out early.

A true positive spotted by scan-build!

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

Helps: #1767
2024-04-12 18:45:31 +01:00
Philip Withnall
6162bccf1f
girffi: Fix ffi_cif leaks on error return paths
Spotted by scan-build.

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

Helps: #1767
2024-04-12 18:45:18 +01:00
Philip Withnall
e45c93da79
girffi: Add hints to indicate ownership transfer into ffi_cif
scan-build thinks that the `atypes` array is leaked, but it’s not.
Ownership is transferred into the `ffi_cif` structure, and it’s
eventually freed in `gi_callable_info_destroy_closure()`.

Try and help the static analysis by adding an explicit ownership
transfer annotation. It probably won’t help.

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

Helps: #1767
2024-04-12 18:45:09 +01:00
Philip Withnall
b8225c905b
gdbusconnection: Ensure out_serial return value is always set
There were some error paths where it wasn’t set, returning an
uninitialised value to the caller.

Spotted by scan-build.

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

Helps: #1767
2024-04-12 18:45:03 +01:00
Philip Withnall
b2f27beb34
build: Enable -Wnull-dereference warning
This enables `NULL` pointer dereference checking in the compiler. This
isn’t as good as static analysis, but it should hopefully catch some
simple errors without too high a false positive rate.

If the false positive rate is too high to be useful, we can always
disable it again.

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

Helps: #1767
2024-04-12 18:44:56 +01:00
Philip Withnall
0f869f3d73
ci: Disable scan-build for copylibs
Eventually, we do want to include them in static analysis (their code is
run in the same process as GLib, after all). But for now, that’s too
much work to get started.

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

Helps: #1767
2024-04-12 18:44:50 +01:00
Philip Withnall
165ae8c8a7
ci: Disable scan-build’s dead code checker
It’s not highlighting severe bugs for us, and currently generates 132
out of 172 of the scan-build reports, so let’s disable it for now.

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

Helps: #1767
2024-04-12 18:44:43 +01:00
Philip Withnall
2dfd9518e1
ci: Exclude tests from scan-build analysis runs
They cause too much noise at the moment. I want to make scan-build
messages fatal, and with 66 of 238 reports coming from the tests,
that’s not currently feasible.

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

Helps: #1767
2024-04-12 18:44:35 +01:00
Philip Withnall
4607dd77a1 Merge branch 'ebassi/drop-unused-cmph-files' into 'main'
Remove unused cmph files

See merge request GNOME/glib!4003
2024-04-12 14:42:52 +00:00
Emmanuele Bassi
52cc4d7b52 Remove unused cmph files
The cmph utility tool is not built, and the licensing of wingetopt.[ch]
is dubious at best.
2024-04-12 15:26:22 +01:00
Philip Withnall
7ec1d6352e Merge branch 'port-gactiongroup-comments' into 'main'
Ports the documentation comments in gio/gactiongroup.c to GI-Docgen

See merge request GNOME/glib!4002
2024-04-12 13:16:36 +00:00
Philip Withnall
978ca4731c
gactiongroup: Add a missing array termination annotation
It might not actually be needed (I haven’t checked if the default is
correct), but it certainly does no harm and makes things explicit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 13:56:20 +01:00
Philip Withnall
3ec4ba4d1b
gactiongroup: Minor copyediting of documentation, comments and warnings
No functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 13:56:07 +01:00
Sudhanshu Tiwari
527e696553 Removed an extra new line in gio/gactiogroup.c 2024-04-12 13:55:51 +01:00
Sudhanshu Tiwari
a43ee8991e Ports the documentation comments in gio/gactiongroup.c to GI-Docgen 2024-04-12 13:55:51 +01:00
Sabri Ünal
204a76669b Update Turkish translation 2024-04-09 10:03:13 +00:00
Philip Withnall
62b65f882a Merge branch 'ebassi/object-connect-docs' into 'main'
docs: Fix g_object_connect()'s docblock

See merge request GNOME/glib!3996
2024-04-08 12:05:31 +00:00
Emmanuele Bassi
b37312f7e4 docs: Fix g_object_connect()'s docblock 2024-04-08 12:05:31 +00:00
Philip Withnall
159d51984b Merge branch 'wip/pwithnall/3314-revert-sigaltstack' into 'main'
Revert "gmain: Use alternate signal stack if the application provides one"

See merge request GNOME/glib!4000
2024-04-08 11:41:50 +00:00
Philip Withnall
3bf2875ce4
Revert "gmain: Use alternate signal stack if the application provides one"
This reverts commit 280c8d41fb.

It breaks the unit tests on macOS (see #3314) and no fix has been
forthcoming.

The alternate stack changes can be resubmitted once they include a
working unit test on macOS, as evidently its treatment of alternate
stacks differs from that on Linux, and hence needs testing.

Helps: #3314
2024-04-08 12:26:40 +01:00
Danial Behzadi
3a1b76ad94 Update Persian translation 2024-04-05 13:58:21 +00:00
Danial Behzadi
2f6ca10f60 Update Persian translation
(cherry picked from commit 1debdc6600)
2024-04-05 13:56:58 +00:00
Michael Catanzaro
a69b346dfd Merge branch '3313-bookmark-spec' into 'main'
gbookmarkfile: Fix link to the Desktop Bookmark Specification

Closes #3313

See merge request GNOME/glib!3995
2024-04-03 15:35:48 +00:00