Commit Graph

22587 Commits

Author SHA1 Message Date
Sebastian Dröge
f83a7d5407 Merge branch 'close-range-enosys' into 'master'
gspawn: Handle ENOSYS from close_range()

See merge request GNOME/glib!1781
2020-12-03 15:29:46 +00:00
Philip Withnall
23f1a31923 gspawn: Handle ENOSYS from close_range()
It’s possible that GLib will eventually be compiled against a version of
libc which supports `close_range()` (hence `HAVE_CLOSE_RANGE` will be
defined), but then run against an older kernel which doesn’t support it.
In this case, we want to fall back to `fdwalk()`, which should work on
such systems.

This is what cpython does: 3529718925/Python/fileutils.c (L2227)

Spotted by Allison Karlitskaya in !1688.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-03 14:30:29 +00:00
Philip Withnall
9a519c8bf0 Merge branch 'selinux-warning' into 'master'
gio: ‘security_context_t’ is deprecated

See merge request GNOME/glib!1776
2020-12-03 13:47:49 +00:00
Daniel Mustieles
48efbc7d6f Updated Spanish translation 2020-12-02 14:16:06 +01:00
Sebastian Dröge
c27f729752 Merge branch 'extend_p_option_for_tests' into 'master'
Extend the usage of -p option for glib test framework

See merge request GNOME/glib!1738
2020-12-02 08:14:12 +00:00
Sebastian Dröge
124d891747 Merge branch '2150-extend-uri-tests' into 'master'
Extends uri test with GstURI inspiration

Closes #2150

See merge request GNOME/glib!1775
2020-12-02 08:05:52 +00:00
Marc-André Lureau
3f18b77fb3 gio: fix set_selinux_context coding style
Mostly for cosmetic and readability, follow more closely the glib-style.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-12-01 13:20:27 +04:00
Marc-André Lureau
f9cc77da73 gio: remove unnecessary strdup and fix potential leak
setfilecon_raw() takes a const argument since libselinux 2.2 (commit
6a17cfaafc)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-12-01 13:16:44 +04:00
Marc-André Lureau
7bd1e09c42 build-sys: bump libselinux requirement to >=2.2
The function declaration we use changed a bit since then.
In particular, some arguments became const. See following commit.

libselinux-2.2 was released on 20131030, and is widely available in
all major stable distributions.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-12-01 13:16:44 +04:00
Marc-André Lureau
20e23c701c gio: ‘security_context_t’ is deprecated
From:
9eb9c93275

"we found that the const security_context_t declarations in libselinux
are incorrect; const char * was intended, but const security_context_t
translates to char * const and triggers warnings on passing const char *
from the caller. Easiest fix is to replace them all with const char *."

And later marked deprecated in commit:
7a124ca275

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-12-01 11:39:00 +04:00
Frederic Martinsons
3872bf2ccf Introduce new options -r (or --run-prefix) and -x (or --skip-prefix)
They extend the behavior of, respectively, -p and -s options of the
glib test framework

Currently test suite are only run for one level under -p path, for
example, testfilemonitor -p /monitor would execute the following tests:

/monitor/atomic-replace
/monitor/file-changes
/monitor/dir-monitor
/monitor/dir-not-existent
/monitor/cross-dir-moves

With the --run-prefix the sub-test suite file will be executed:

/monitor/atomic-replace
/monitor/file-changes
/monitor/dir-monitor
/monitor/dir-not-existent
/monitor/cross-dir-moves
/monitor/file/hard-links

The --skip-prefix and run-prefix seems symmetrical, but there is a
difference with skip towards run:
--skip-prefix will use a prefix while --run-prefix only work for a valid test path.
For example and for the following test family:

/monitor/atomic-replace
/monitor/file-changes
/monitor/dir-monitor
/monitor/dir-not-existent
/monitor/cross-dir-moves
/monitor/file/hard-links

while --run-prefix /mon will not execute anything, --skip-prefix /mon
 will skip all of these tests.

See #2238 which references this change.
2020-11-30 14:42:58 +01:00
Frederic Martinsons
1d221af7f1 Extends uri test with GstURI inspiration
- Add a test for parsing FILE scheme from uri
It had taken from GST test_protocol_case
- Add a split uri test with encoded spaces in its path
It had taken from GST test_uri_get_location
- Add tests for g_uri_is_valid
It had taken from GST test_uri_misc
Note that the 4 followings uri failed under gst_uri_is_valid but not
under g_uri_is_valid
   B:\\foo.txt
   B:/foo.txt
   B://foo.txt
   B:foo.txt
- Add tests for g_uri_split
It had taken from GST test_url_parsing
- Add tests for test_uri_normalize and test_uri_parsing_relative
The test URI had been taken from GST test_url_normalization
- Add tests for test_uri_iter_params
It had taken from GST test_url_unescape_equals_in_http_query

Closes #2150

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-11-30 14:34:06 +01:00
Marek Černocký
159ed036d4 Updated Czech translation 2020-11-28 16:56:59 +01:00
Philip Withnall
0af274faa4 Merge branch 'macos-cross' into 'master'
macos: fix frexpl checks in cross-compilation

See merge request GNOME/glib!1771
2020-11-25 19:11:19 +00:00
Philip Withnall
3088fbae52 Merge branch 'mark_g_assert_as_noreturn_on_MSVC' into 'master'
Adding macros G_NORETURN and G_NORETURN_FUNCPTR

Closes #994

See merge request GNOME/glib!1078
2020-11-25 11:52:23 +00:00
Philip Withnall
9cccc08b82 gmacros: Document soft-deprecation of G_GNUC_NORETURN
It still works, and deprecating it would be quite disruptive (as it’s
used in headers), so amend the documentation to point people to
`G_NORETURN` instead.

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

Helps: #994
2020-11-25 11:37:06 +00:00
Emmanuel Fleury
76426c0158 Rewriting the G_GNUC_NORETURN into G_NORETURN macros everywhere 2020-11-25 11:34:05 +00:00
Emmanuel Fleury
c1d74e35c1 Adding macros G_NORETURN and G_NORETURN_FUNCPTR
This macro is borrowed from the gnulib project in the 'noreturn.h' file.

Fixes: #994
2020-11-25 11:34:05 +00:00
Patrick Griffis
a5944828ae Merge branch 'carlosgc/uri-scheme-normalization' into 'master'
guri: apply scheme normalization flag consistently

Closes #2257

See merge request GNOME/glib!1764
2020-11-24 17:25:26 +00:00
Philip Withnall
77361ef45e Merge branch 'fix_extra_warnings' into 'master'
Fix more warnings

See merge request GNOME/glib!1765
2020-11-24 15:37:21 +00:00
Emmanuel Fleury
236d6281b8 Fix signedness warnings in gobject/gobject.c:g_object_new_internal()
gobject/gobject.c: In function ‘g_object_new_internal’:
gobject/gobject.c:1962:25: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
 1962 |           for (j = 0; j < n_params; j++)
      |                         ^
gobject/gobject.c:1989:21: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
 1989 |       for (i = 0; i < n_params; i++)
      |                     ^
2020-11-24 16:17:46 +01:00
Emmanuel Fleury
7753a0492b Fix signedness warnings in gobject/gobject.c:g_object_new_with_custom_constructor()
gobject/gobject.c: In function ‘g_object_new_with_custom_constructor’:
gobject/gobject.c:1836:21: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
 1836 |       for (j = 0; j < n_params; j++)
      |                     ^
gobject/gobject.c:1914:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
 1914 |   for (i = 0; i < n_params; i++)
      |                 ^
2020-11-24 16:17:46 +01:00
Emmanuel Fleury
d50d2098b5 Fix signedness warning in gobject/gobject.c:g_object_class_install_properties()
gobject/gobject.c: In function ‘g_object_class_install_properties’:
gobject/gobject.c:766:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  766 |   for (i = 1; i < n_pspecs; i++)
      |                 ^
2020-11-24 16:17:46 +01:00
Emmanuel Fleury
e28d9defb1 Fix signedness warning in gobject/gtype.c:g_type_interface_add_prerequisite()
gobject/gtype.c: In function ‘g_type_interface_add_prerequisite’:
gobject/gtype.c:1607:21: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘int’
 1607 |       for (i = 0; i < prerequisite_node->n_supers + 1; i++)
      |                     ^
2020-11-24 16:17:37 +01:00
Philip Withnall
69f0f33267 Merge branch 'mcatanzaro/#2076' into 'master'
Suppress some valgrind leak warnings

Closes #2076

See merge request GNOME/glib!1768
2020-11-24 14:45:11 +00:00
Michael Catanzaro
fb6e10c959 gtype: suppress valgrind memory leak warnings
The problem occurs because we keep a pointer inside the allocated block,
instead of a pointer to the start of the block. This memory exists for
the lifetime of the application, so let's silence it.

This is probably abuse of VALGRIND_MALLOCLIKE_BLOCK(), which is really
intended for use in memory allocators, but gtype.c already uses it in
two other places, and it's a practical solution. I wrote another larger
fix for this issue that involves keeping an array of extra pointers when
running under valgrind. This is simpler.

Fix suggested by Philip Withnall

```
==180238== 16 bytes in 1 blocks are possibly lost in loss record 3,078 of 16,075
==180238==    at 0x483BB1A: calloc (vg_replace_malloc.c:762)
==180238==    by 0x5489495: g_malloc0 (gmem.c:132)
==180238==    by 0x5489754: g_malloc0_n (gmem.c:364)
==180238==    by 0x53FDBEE: type_set_qdata_W (gtype.c:3722)
==180238==    by 0x53FDEE8: type_add_flags_W (gtype.c:3787)
==180238==    by 0x53FC348: g_type_register_fundamental (gtype.c:2662)
==180238==    by 0x53D969B: _g_enum_types_init (genums.c:124)
==180238==    by 0x53FF058: gobject_init (gtype.c:4432)
==180238==    by 0x53FF082: gobject_init_ctor (gtype.c:4493)
==180238==    by 0x4010F29: call_init.part.0 (dl-init.c:72)
==180238==    by 0x4011030: call_init (dl-init.c:30)
==180238==    by 0x4011030: _dl_init (dl-init.c:119)
==180238==    by 0x4002149: ??? (in /usr/lib64/ld-2.30.so)
```

Fixes #2076
2020-11-24 08:10:58 -06:00
Michael Catanzaro
a412ffe4d3 gatomicarray: suppress valgrind memory leak warnings
The problem occurs because we keep a pointer inside the allocated block,
instead of a pointer to the start of the block:

```
==180238== 16 bytes in 1 blocks are possibly lost in loss record 3,086 of 16,075
==180238==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==180238==    by 0x548942C: g_malloc (gmem.c:102)
==180238==    by 0x54A4748: g_slice_alloc (gslice.c:1025)
==180238==    by 0x53D0AAF: freelist_alloc (gatomicarray.c:77)
==180238==    by 0x53D0B85: _g_atomic_array_copy (gatomicarray.c:133)
==180238==    by 0x53F8E6D: iface_node_set_offset_L (gtype.c:1347)
==180238==    by 0x53F91F1: type_node_add_iface_entry_W (gtype.c:1444)
==180238==    by 0x53F93DF: type_add_interface_Wm (gtype.c:1477)
==180238==    by 0x53FC946: g_type_add_interface_static (gtype.c:2852)
==180238==    by 0x4A3D53A: gtk_menu_shell_accessible_get_type_once (gtkmenushellaccessible.c:26)
==180238==    by 0x4A3D495: gtk_menu_shell_accessible_get_type (gtkmenushellaccessible.c:26)
==180238==    by 0x4C8AC44: gtk_menu_shell_class_init (gtkmenushell.c:424)
```

Note we cannot use VALGRIND_FREELIKE_BLOCK() in freelist_free() because we
have not actually freed the FreeListNode and need to dereference it in
freelist_alloc() to decide whether to reuse the block. That would result
in a use-after-free warning before we would get a chance to call
VALGRIND_MALLOCLIKE_BLOCK() in the reuse path.

Also note that this free list only ever grows: it never shrinks for the
lifetime of the application, so nothing here will ever be truely freed,
although unused elements are eligible for reuse.

Fix suggested by Philip Withnall

Related: #2076
2020-11-24 08:10:58 -06:00
Carlos Garcia Campos
fb838bf3f6 guri: apply scheme normalization flag consistently
For URIs produced in string form, the path should be normalized and port
omitted when the default one is used. When querying the path and port of
a GUri (using getters or g_uri_split()) the normalized path and the
default port should be returned when they were omitted in the parsed URI.

Closes #2257
2020-11-24 14:35:19 +01:00
Andoni Morales Alastruey
64dda3ad87 macos: fix frexpl checks in cross-compilation
Cross-compilation to arm64 for Apple Silicon is not possible
due to the hardcoded settings for frexpl.
See: #1868
2020-11-24 13:05:17 +00:00
Philip Withnall
23ad18791d Merge branch 'mcatanzaro/coverity-checked-return' into 'master'
gkeyfilesettingsbackend: improve error-checking

See merge request GNOME/glib!1746
2020-11-24 10:44:59 +00:00
Philip Withnall
44fede46be Merge branch 'wip/jfelder/gdatetime-annotations' into 'master'
Fix some gdatetime annotations

See merge request GNOME/glib!1766
2020-11-24 10:36:38 +00:00
Philip Withnall
9aaac19173 Merge branch 'wip/pwithnall/disable-assert' into 'master'
gfileicon: Fix unused-but-set variable with G_DISABLE_ASSERT

See merge request GNOME/glib!1769
2020-11-24 10:10:26 +00:00
Michael Catanzaro
00e8064137 gkeyfilesettingsbackend: improve error checking
Coverity noticed that we are ignoring return values in a couple places
here. We should print warnings when appropriate.
2020-11-24 10:09:02 +00:00
Jean Felder
cd6b35f7d2 gdatetime: Fix g_date_time_equal annotation
The parameters C type need to be overriden to GDateTime.
2020-11-24 09:45:58 +00:00
Jean Felder
b513b358a8 gdatetime: Fix g_date_time_hash annotation
The parameter C type needs to be overriden to GDateTime.
2020-11-24 09:45:58 +00:00
Jean Felder
7ec3c26e67 gdatetime: Fix g_date_time_compare annotation
The parameters C type need to be overriden to GDateTime.
2020-11-24 09:45:58 +00:00
Philip Withnall
44c4e42151 gfileicon: Fix unused-but-set variable with G_DISABLE_ASSERT
This fixes a warning (which is promoted to an error) in our
`G_DISABLE_ASSERT` CI.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-24 09:44:48 +00:00
Sebastian Dröge
d78778cc46 Merge branch 'scan-build-fixes' into 'master'
Minor scan-build fixes

See merge request GNOME/glib!1770
2020-11-24 09:40:34 +00:00
Sebastian Dröge
ec981cf570 Merge branch 'wip/pwithnall/553-tz-freebsd-tests' into 'master'
tests: Fix GDateTime tests on FreeBSD

See merge request GNOME/glib!1767
2020-11-24 09:33:47 +00:00
Philip Withnall
6e446931a8 tests: Add a test to avoid a set-but-unused variable
Spotted by `scan-build`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-24 09:21:45 +00:00
Philip Withnall
eafc6b257c tests: Add a test to avoid a set-but-unused variable
Spotted by `scan-build`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-24 09:21:45 +00:00
Philip Withnall
6fcc4db228 tests: Drop dead code from GDateTime test
Spotted by `scan-build`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-24 09:21:45 +00:00
Philip Withnall
2237db78f1 tests: Fix GDateTime tests on FreeBSD
`g_time_zone_new_identifier()` returns NULL in the FreeBSD test setup,
presumably because `TZ` isn’t set.

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

Helps: #553
2020-11-24 09:20:28 +00:00
Emmanuel Fleury
6b0552bb89 Fix signedness warning in gobject/gtype.c:type_node_add_iface_entry_W()
gobject/gtype.c: In function ‘type_node_add_iface_entry_W’:
gobject/gtype.c:1379:21: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘int’
 1379 |       for (i = 0; i < num_entries; i++)
      |                     ^
2020-11-22 17:10:53 +01:00
Emmanuel Fleury
f6e234fdb6 Fix signedness warning in gobject/gtype.c:lookup_iface_entry_I()
gobject/gtype.c: In function ‘lookup_iface_entry_I’:
gobject/gtype.c:599:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  599 |       if (index < IFACE_ENTRIES_N_ENTRIES (entries))
      |                 ^
gobject/gatomicarray.h:51:8: note: in definition of macro ‘G_ATOMIC_ARRAY_DO_TRANSACTION’
   51 |       {_C_;}         \
      |        ^~~
2020-11-22 17:10:53 +01:00
Sebastian Dröge
72360eb8bd Merge branch '553-tz-errors' into 'master'
gtimezone: Add new constructor which can report errors

Closes #553

See merge request GNOME/glib!1760
2020-11-22 08:35:33 +00:00
Philip Withnall
3356934db5 gtimezone: Deprecate g_time_zone_new()
Use `g_time_zone_new_identifier()` instead so you can get error
checking.

Adapt the tests to match.

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

Helps: #553
2020-11-21 23:11:23 +00:00
Philip Withnall
9f041c9e05 Merge branch 'th/gobject-new-parameter-list' into 'master'
gobject: allocate parameter list for g_object_new_valist() entirely on stack

See merge request GNOME/glib!1385
2020-11-21 22:55:55 +00:00
Sebastian Dröge
fa8a39c6c6 Merge branch 'py-fixes' into 'master'
Python formatting improvements

See merge request GNOME/glib!1757
2020-11-20 18:10:40 +00:00
Philip Withnall
a7c0adbe11 Merge branch 'py-sh-check-fixes' into 'master'
shellcheck fixes

See merge request GNOME/glib!1756
2020-11-20 15:01:59 +00:00