Commit Graph

22964 Commits

Author SHA1 Message Date
Sebastian Dröge
18f8a8b25f Merge branch '1568-initially-unowned-docs' into 'master'
docs: Mention GInitiallyUnowned when introducing refcounts

Closes #1568

See merge request GNOME/glib!1798
2020-12-12 20:48:42 +00:00
Philip Withnall
e7f9ae61dc docs: Mention GInitiallyUnowned when introducing refcounts
For completeness.

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

Fixes: #1568
2020-12-12 18:47:00 +00:00
Philip Withnall
c58f308aed tests: Be more lenient with timing checks on asyncqueue pops
On heavily loaded CI machines it seems to be taking about 1.3s between
one `g_get_monotonic_time()` call and the next. Allow that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-12 18:41:50 +00:00
Philip Withnall
ff56386788 tests: Add some rounding tolerance in timeout test
Occasionally this test fails in CI with the message:
```
assertion failed: (current_time / 1000000 - last_time / 1000000 == 1)
```

The way this calculation is done at the moment, a difference of 1001ms
between `current_time` and `last_time` can result in failure, if the
times are close to a multiple to 1000ms.

Change it to only truncate the result after doing the subtraction, and
add a 500ms tolerance to account for scheduling delays in the test. (For
example, the `test_func()` could be called, then descheduled before it
gets to call `g_get_monotonic_time()`.

Additionally, change the test to use `g_assert_cmpint()` so that future
failures provide more useful debug information.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-12 18:41:08 +00:00
Philip Withnall
39f33412db python: Reformat some files to keep style-check-diff happy
The version of `black` on the CI server wanted these changes. Make them
to keep the `style-check-diff` CI job from constantly failing.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-12 18:40:57 +00:00
Philip Withnall
0755ff97be gchecksum: Drop preconditions for checksum_type being valid
Instead, return `NULL` if the checksum type is unsupported. This may
come in useful if we have to withdraw support for a particular checksum
type in future, due to it being broken.

These semantics were already in place for the return value of
`g_checksum_new()` — see commit 877cc60f and bug
comment https://bugzilla.gnome.org/show_bug.cgi?id=501853#c6.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-12 18:30:22 +00:00
Philip Withnall
3fef049472 gchecksum: Add missing (transfer) and (nullable) return annotations
This commit only looks at the `Returns:` lines in the documentation, and
has examined all of them in the file. Function arguments have not been
checked.

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

Helps: #2227
2020-12-12 18:30:22 +00:00
Philip Withnall
da83d711d6 gbookmarkfile: Add missing (transfer) and (nullable) return annotations
This commit only looks at the `Returns:` lines in the documentation, and
has examined all of them in the file. Function arguments have not been
checked.

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

Helps: #2227
2020-12-12 18:30:22 +00:00
Philip Withnall
7c3891afe9 gasyncqueue: Add missing (transfer) and (nullable) return annotations
This commit only looks at the `Returns:` lines in the documentation, and
has examined all of them in the file. Function arguments have not been
checked.

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

Helps: #2227
2020-12-12 18:30:22 +00:00
Philip Withnall
f53b3f3a16 garray: Add missing (transfer) and (nullable) return annotations
This commit only looks at the `Returns:` lines in the documentation, and
has examined all of them in the file. Function arguments have not been
checked.

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

Helps: #2227
2020-12-12 18:30:22 +00:00
Ondrej Holy
c311b9947b gio-tool-info: Prevent criticals if mount options are not available
NULL is valid return value for the g_unix_mount_get_options function
because mount options are currently provided only by libmount implementation.
However, the gio tool passes the returned value to the g_strescape function
without checking, which produces the following critical warning:
GLib-CRITICAL **: 13:47:15.294: g_strescape: assertion 'source != NULL' failed

Let's add the missing check to prevent the critical warnings.
2020-12-12 18:30:22 +00:00
Sebastian Dröge
a4be8577ed Merge branch 'wip/pwithnall/freebsd-math' into 'master'
gdatetime: Improve ISO 8601 parsing to avoid floating point checks

See merge request GNOME/glib!1797
2020-12-12 18:15:48 +00:00
Philip Withnall
7ad0c3a0f4 gsignal: Add (closure) and (destroy) annotations
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-12 18:08:40 +00:00
Philip Withnall
d2cd34969a gparam: Fix transfer annotation for g_param_spec_internal()
`GParamSpec`s are floating by default.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-12 17:59:45 +00:00
Sebastian Dröge
975603d74f Merge branch '769778-dbus_register-contract' into 'master'
gapplication: Add postconditions on calls to GApplication.dbus_register

Closes #1188

See merge request GNOME/glib!1800
2020-12-12 09:01:00 +00:00
Emmanuele Bassi
adaca14133 Merge branch '2227-more-nullables-more' into 'master'
gobject: More missing return value annotations

See merge request GNOME/glib!1802
2020-12-12 00:04:31 +00:00
Philip Withnall
181a12c393 gsignal: Add missing (transfer) and (nullable) return annotations
This commit only looks at the `Returns:` lines in the documentation, and
has examined all of them in the file. Function arguments have not been
checked.

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

Helps: #2227
2020-12-11 23:49:30 +00:00
Philip Withnall
c7a7dd9ae3 gparam: Add missing (transfer) and (nullable) return annotations
This commit only looks at the `Returns:` lines in the documentation, and
has examined all of them in the file. Function arguments have not been
checked.

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

Helps: #2227
2020-12-11 23:49:14 +00:00
Philip Withnall
a9e3e3715a genums: Add missing (transfer) and (nullable) return annotations
This commit only looks at the `Returns:` lines in the documentation, and
has examined all of them in the file. Function arguments have not been
checked.

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

Helps: #2227
2020-12-11 23:48:35 +00:00
Philip Withnall
539621d2d3 gapplication: Add postconditions on calls to GApplication.dbus_register
Try and catch programmer errors in third-party implementations of
`dbus_register()`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1188
2020-12-11 22:33:13 +00:00
Philip Withnall
f7dbc6010b tests: Add more tests for GDateTime ISO 8601 seconds parsing
This should add a few more lines/branches to the test coverage.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-11 16:03:11 +00:00
Philip Withnall
50a3d0bf9d gdatetime: Use isnan() instead of !isfinite()
Both are provided by libm, but `isnan()` is provided as a macro, whereas
`isfinite()` is an actual function, and hence libm has to be available
at runtime. That didn’t trivially work on FreeBSD, resulting in this
refactor.

`isfinite(x)` is equivalent to `!isnan(x) && !isinfinite(x)`. The case
of `x` being (negative or positive) infinity is already handled by the
range checks on the next line, so it’s safe to switch to `isnan()` here.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-11 15:39:47 +00:00
Philip Withnall
5d7f4b8f04 gdatetime: Remove floating point from seconds parsing code
Rather than parsing the seconds in an ISO 8601 date/time using a pair of
floating point numbers (numerator and denominator), use two integers
instead. This avoids issues around floating point precision, and also
makes it easier to check for potential overflow from overlong inputs.

This last point means that the `isfinite()` check can be removed, as it
was covering the case where a NAN was generated, which isn’t now
possible using integer arithmetic.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-11 15:36:56 +00:00
Philip Withnall
819409cf9a Merge branch 'wip/oholy/gio-info-prevent-criticals' into 'master'
gio-tool-info: Prevent criticals if mount options are not available

See merge request GNOME/glib!1794
2020-12-11 13:41:22 +00:00
Ondrej Holy
48a84f6434 gio-tool-info: Prevent criticals if mount options are not available
NULL is valid return value for the g_unix_mount_get_options function
because mount options are currently provided only by libmount implementation.
However, the gio tool passes the returned value to the g_strescape function
without checking, which produces the following critical warning:
GLib-CRITICAL **: 13:47:15.294: g_strescape: assertion 'source != NULL' failed

Let's add the missing check to prevent the critical warnings.
2020-12-11 13:18:27 +00:00
Sebastian Dröge
a28b3c9dd6 Merge branch 'fix-set-contents-typo' into 'master'
gfileutils: Fix typo in docs

See merge request GNOME/glib!1796
2020-12-11 07:27:38 +00:00
Phaedrus Leeds
7ef936f4e3 gfileutils: Fix typo in docs 2020-12-10 21:06:00 -08:00
Florentina Mușat
673f61a763 Update Romanian translation 2020-12-10 16:24:45 +00:00
Yuri Chornoivan
df42290300 Update Ukrainian translation 2020-12-09 15:43:41 +00:00
Sebastian Dröge
68e8fc85b4 Merge branch 'ossfuzz-28473-date-time-iso8601' into 'master'
gdatetime: Disallow NAN as a number of seconds in a GDateTime

See merge request GNOME/glib!1791
2020-12-09 15:12:44 +00:00
Philip Withnall
7e63bc8eb1 Merge branch 'master' into 'master'
array: Avoid sorting 0-sized arrays

Closes #2264

See merge request GNOME/glib!1789
2020-12-09 15:11:57 +00:00
Timm Bäder
c2052a4ada array: Avoid sorting 0-sized arrays
Fixes #2264
2020-12-09 14:52:56 +00:00
Philip Withnall
c3805d74ba gdatetime: Disallow NAN as a number of seconds in a GDateTime
The fiendish thing about NAN is that it never compares TRUE against
anything, so the limit checks `seconds < 0.0 || seconds >= 60.0` were
never triggering.

oss-fuzz#28473

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 14:50:02 +00:00
Sebastian Dröge
737a853f8d Merge branch 'wip/pwithnall/2119-osx-app-info' into 'master'
Debuggability improvements in gosxappinfo.m

See merge request GNOME/glib!1787
2020-12-09 12:43:20 +00:00
Sebastian Dröge
e17c5d78fe Merge branch 'ossfuzz-28458-date-overflow' into 'master'
gdate: Validate input as UTF-8 before parsing

See merge request GNOME/glib!1788
2020-12-09 12:41:32 +00:00
Ondrej Holy
aa1e91e838 Merge branch '2098-add-gio-restore-support' into 'master'
Add restore option for trash gio-tool subcommand

Closes #2098

See merge request GNOME/glib!1778
2020-12-09 12:40:59 +00:00
Ondrej Holy
0458ad893a Merge branch '54-add-gio-launch-command' into 'master'
Add gio launch command to execute desktop file

Closes #54

See merge request GNOME/glib!1779
2020-12-09 12:36:41 +00:00
Philip Withnall
b4c2e4d553 gdate: Validate input as UTF-8 before parsing
Dates have to be valid UTF-8.

oss-fuzz#28458

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 12:07:41 +00:00
Philip Withnall
a9fc7e5935 gosxappinfo: Add some more precondition checks
These might help catch the problem in #2119 earlier on, and provide more
information about its root cause.

They should not affect behaviour in normal application usage.

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

Helps: #2119
2020-12-09 11:44:37 +00:00
Philip Withnall
2a629b3b4b gosxappinfo: Use strlen() instead of some magic constants
This is equivalent, but makes the code a bit more readable.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 11:44:14 +00:00
Philip Withnall
1862a900b1 gosxappinfo: Fix some const-correctness issues
This is technically an API break, as the following assignment may now
raise warnings in user code:
```
gchar *filename = g_osx_app_info_get_filename (app_info);
```

However, from code search it seems like the number of users of that
function is zero.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 11:41:38 +00:00
Frederic Martinsons
c3a073e96f Add gio launch command to execute desktop file
This command will try to execute a desktop file, before that
it will load the input as a keyfile for checking its existence
and its validity (as a keyfile).
File arguments are allowed after the desktop file.

Closes #54

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-12-09 08:15:42 +01:00
Philip Withnall
ba62118122 Merge branch 'weak-notify-dispose' into 'master'
Handle the case of g_object_run_dispose() in GBinding

Closes #2265

See merge request GNOME/glib!1786
2020-12-08 19:57:27 +00:00
Sebastian Dröge
e82eb490fe Handle the case of g_object_run_dispose() in GBinding
When this is called on the source or target, the weak notify of the
corresponding object is called without the GWeakRef being cleared.
See https://gitlab.gnome.org/GNOME/glib/-/issues/2266 for that issue.

This means that a strong reference to these zombie objects can be
retrieved from the GWeakRefs and the previous assumption that this can't
happen was wrong. Remove the assertion for that accordingly and handle
this case.

Specifically, all signal handlers and weak notifies of the object are
already gone and must not be disconnected/removed a second time, or
otherwise memory corruption would be caused. Instead just set the
GWeakRef to NULL and handle it otherwise as if the GWeakRef didn't give
a strong reference to begin with.

Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2265
2020-12-08 18:41:27 +02:00
Sebastian Dröge
a2de4b2479 Clarify in g_object_weak_ref() docs that the callback is called during disposing and not finalizing
This especially has the effect that any GWeakRefs to the object will not
necessarily be set to NULL yet if called as part of
g_object_run_dispose() and not as part of g_object_unref().
2020-12-08 18:09:50 +02:00
Philip Withnall
c3f613af0c Merge branch 'coverity-fixes' into 'master'
glocalfile: Add an assertion to help static analysis

See merge request GNOME/glib!1785
2020-12-08 15:56:05 +00:00
Sebastian Dröge
ec330e50cf Merge branch 'more-fuzzing' into 'master'
fuzzing: Add more fuzzing tests for various string parsing functions

See merge request GNOME/glib!1784
2020-12-08 15:10:14 +00:00
Philip Withnall
d5778ec479 gvariant: Clarify operator precedence
This doesn’t change the behaviour of the code, but should squash some
compiler/static analysis warnings about ‘are you sure you got the
precedence right here?’.

Coverity CID: #1159470

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-08 12:17:00 +00:00
Philip Withnall
3a7acd24a9 glocalfile: Add an assertion to help static analysis
Static analysis of the call to `g_dir_new_from_dirp()` is tricky,
because the call is across library boundaries and indirected through a
vfunc map because it’s private to libglib.

Help the static analyser by adding an assertion about the input and
output values for `g_dir_new_from_dirp()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-08 11:16:43 +00:00
Philip Withnall
105f4a0f39 fuzzing: Add more fuzzing tests for various string parsing functions
There’s no explicit guarantee that any of these functions are safe to
use on untrusted data, but it does no harm to test them.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-08 11:07:43 +00:00