Commit Graph

19699 Commits

Author SHA1 Message Date
Tomasz Miąsko
b599a0f414 gdbusintrospection: Use atomic operations to read ref_count 2018-11-06 14:44:40 +01:00
Tomasz Miąsko
b5a41afb18 gvarianttypeinfo: Use gatomicrefcount for ContainerInfo reference count 2018-11-06 14:44:25 +01:00
Tomasz Miąsko
6d108587a4 gvariant-core: Use gatomicrefcount for GVariant reference count 2018-11-06 14:39:19 +01:00
Philip Withnall
409ff69bd1 gvariant: Re-use g_variant_serialised_check() to check alignment
Rather than duplicating the alignment checks when constructing a new
GVariant, re-use the alignment checks from GVariantSerialised. This
ensures that the same checks are done everywhere in the GVariant code.

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

https://gitlab.gnome.org/GNOME/glib/issues/1342
2018-11-06 12:49:25 +00:00
Philip Withnall
a3ad5a2ce0 Merge branch 'bookmarkfile-self-move' into 'master'
bookmarkfile: Don't move an item if the uri has not changed

Closes #1588

See merge request GNOME/glib!456
2018-11-06 12:21:19 +00:00
Philip Withnall
7b0f2e0e34 gvariant: Fix some GIR annotations on internal functions
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 11:50:20 +00:00
Philip Withnall
0f2a6c61c9 gvariant: Realign data on construction if it’s not properly aligned
Otherwise the GVariant would later fail internal alignment checks,
aborting the program.

If unaligned data is provided to (for example)
g_variant_new_from_data(), it will copy the data into a new aligned
allocation. This is slow, but better than crashing. If callers want
better performance, they should provide aligned data in their call, and
it will not be copied or reallocated.

Includes a unit test.

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

https://gitlab.gnome.org/GNOME/glib/issues/1342
2018-11-06 11:50:20 +00:00
Marco Trevisan (Treviño)
cfd164980d gbookmarkfile: remove trailing spaces 2018-11-05 17:15:42 -06:00
Marco Trevisan (Treviño)
821d28024b bookmarkfile: Don't move an item if the uri has not changed
This was causing a crash, because we were first removing an item, freeing
both the instance itself and the key, and then trying to reuse those.

So, in this case, instead of reassigning an item, we can just return TRUE
as we have already the item at the right place, while it's not needed to
update the modified timestamp, since no modification happened in reality.

Fixes #1588
2018-11-05 17:15:32 -06:00
Marco Trevisan (Treviño)
94edafb5fa bookmarkfile: test that moving to the same name works
Verify that we can move a bookmark item to the same name, but actually this
causes a crash right now.
2018-11-05 17:06:52 -06:00
Tomasz Miąsko
68e78c6eb2 tests: Fix data races in gwakeuptest.c 2018-11-04 17:28:58 +01:00
Tomasz Miąsko
1cc7457870 tests: Fix data races in refcount/signals.c 2018-11-04 17:28:51 +01:00
Tomasz Miąsko
83221671ea tests: Fix data races in refcount/closures.c 2018-11-04 17:28:43 +01:00
Philip Withnall
b09a0df9a9 Merge branch '1576-meson-armv5-atomic' into 'master'
meson: Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 on GNU/Linux if needed

Closes #1576

See merge request GNOME/glib!434
2018-11-02 20:56:37 +00:00
Philip Withnall
73a982fa91 Merge branch 'wip/sadiq/likely' into 'master'
gmacros: Fix G_[UN]LIKELY to not mask -Wparentheses

See merge request GNOME/glib!372
2018-11-02 20:45:38 +00:00
Philip Withnall
5c7e64ae77 Merge branch 'supp' into 'master'
valgrind: Add glib_init()-related suppressions

See merge request GNOME/glib!436
2018-11-02 20:34:53 +00:00
Philip Withnall
74d2a8e500 Merge branch 'test-timeout' into 'master'
meson: Increase test timeouts

See merge request GNOME/glib!407
2018-11-02 11:02:32 +00:00
Philip Withnall
8f115b63b1 Merge branch 'atomic-ref-count' into 'master'
gvarianttypeinfo: Consistently use atomics to access ref_count

See merge request GNOME/glib!444
2018-11-02 10:29:48 +00:00
Philip Withnall
7d4fb4df78 Merge branch 'g-test-rand-int-range-race' into 'master'
tests: Avoid multithreaded use of g_test_rand_int_range

See merge request GNOME/glib!443
2018-11-02 10:21:20 +00:00
Tomasz Miąsko
aed3c0083b gtestutils: Make test_rand_* thread-safe within a single test case
Synchronize access to random number generator `test_run_rand` with
a lock to ensure that `g_test_rand_*` family of functions is
thread-safe.

The reseeding taking place between test case runs is intentionally left
unsynchronized. It is an error to continue using random number generator
after test case has already finished running. Lack of synchronization
here will make such erroneous use readily apparent with thread
sanitizer.
2018-11-02 08:29:08 +01:00
Tomasz Miąsko
03518e576e gvarianttypeinfo: Consistently use atomics to access ref_count 2018-11-01 21:55:07 +01:00
Simon McVittie
03413d5a87 meson: Mark gdatetime test as slow
This test isn't inherently slow, but it produces so much output that
it can take a minute or more on hardware with weak I/O performance.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:13:21 +00:00
Simon McVittie
a40ef2ff92 meson: Increase fast test timeout from 30s to 60s
This is enough for most Debian buildds, including embedded devices
like mips and powerpcspe. It is not enough for hppa (PA-RISC), but that
architecture is so uniquely slow that it might make more sense to
special-case it downstream.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:13:21 +00:00
Simon McVittie
13e206aaeb meson: Centralize test timeout values
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:13:21 +00:00
Matthias Clasen
d3f5559780 Merge branch '1575-revert-strftime-format' into 'master'
Revert "gdatetime: Enable compile time check of g_date_time_format() format"

Closes #1575

See merge request GNOME/glib!442
2018-11-01 18:12:41 +00:00
Dušan Kazik
e1056e5979 Update Slovak translation
(cherry picked from commit 985210849c)
2018-11-01 18:05:52 +00:00
Philip Withnall
664fb6303b Revert "gdatetime: Enable compile time check of g_date_time_format() format"
This reverts commits:
 • 9ddcc79502ae02adc3c3

g_date_time_format() supports a few non-standard format placeholders:
 • %:z
 • %::z
 • %:::z

These are all gnulib strtime() extensions, and hence are not recognised
by the compiler when the function is annotated with G_GNUC_STRFTIME.
However, this wasn’t noticed when we originally merged this change
because the errors were disabled in the tests which covered those
placeholders.
2018-11-01 16:12:32 +00:00
Matthias Clasen
9ddcc79502 Remove the G_GNUC_STRFTIME format check
This does not work, since g_date_time_format() supports
non-standard extensions such as %:::z, and this has
broken several consumers which use format errors, such
as ostree.
2018-11-01 12:00:58 -04:00
Philip Withnall
bfc661a1db Merge branch 'tests-memory-leaks' into 'master'
Fix minor memory leaks in tests

See merge request GNOME/glib!440
2018-11-01 11:59:59 +00:00
Tomasz Miąsko
b7571d5f0f tests: Fix GVariantType leak in GAction tests 2018-11-01 12:15:09 +01:00
Tomasz Miąsko
52bab0254a tests: Fix GOptionContext leak in GSubprocess tests 2018-11-01 12:14:52 +01:00
Tomasz Miąsko
9347c7630f tests: Fix GRand leak in GMenuModel tests 2018-11-01 12:14:09 +01:00
Philip Withnall
afce4ef36b Merge branch 'flags_validation_fix' into 'master'
gobject/genums.c: fix flags validation

Closes #1572

See merge request GNOME/glib!401
2018-11-01 10:46:29 +00:00
Arthur Demchenkov
aa1415c0df Add unit test for flags validation 2018-11-01 01:41:32 +03:00
Arthur Demchenkov
1d6c7843ca gobject/genums.c: fix flags validation
gint -> glong conversion causes flags to be invalid if the highest bit
is set.

Closes #1572
2018-11-01 01:41:32 +03:00
Philip Withnall
4f81c9eb97 Merge branch 'gdate-timezone' into 'master'
gdatetime: Fix formatting of time zones offsets in range -01:00 to +00:00

See merge request GNOME/glib!435
2018-10-31 22:35:00 +00:00
Philip Withnall
e7738e46a8 Merge branch 'mr/issue-1575' into 'master'
Enable compile time check of g_date_time_format() format

See merge request GNOME/glib!412
2018-10-31 22:23:50 +00:00
Philip Withnall
da790bc6da Merge branch 'gvariant' into 'master'
Fix ^*ay handling in g_variant_iter_loop()

See merge request GNOME/glib!417
2018-10-31 22:16:02 +00:00
Olivier Brunel
63e09d5251 valgrind: Add glib_init()-related suppressions 2018-10-31 19:43:59 +01:00
Christophe Fergeau
bd6d603398 test-gvariant: Add missing spaces before parens
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:44:21 +01:00
Christophe Fergeau
38d48b818a test-gvariant: Add and use assert_cmpstrv helper
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:44:21 +01:00
Christophe Fergeau
422d83cbaa test-gvariant: Remove some hardcoded strings
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:43:19 +01:00
Christophe Fergeau
572f78b649 test-gvariant: Use g_assert_* rather than g_assert()
This is desirable both to get more detailed failure messages; and
because g_assert() is compiled out when compiling with G_DISABLE_ASSERT,
which renders the tests useless.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:43:17 +01:00
Christophe Fergeau
e6e04d3b15 test-gvariant: Use gsize for loop indices
gint is not the best type when looping from 0 to N > 0, which usually is
the case in loops.  There are a few cases in this patch where guint is
used rather than gsize, this is when the index is used in a printf-like
function as this makes the format string easier to read

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:41:00 +01:00
Christophe Fergeau
b0a013e20e gvariant: Handle ^ay, ^&ay, ^aay, ^a&ay in g_variant_valist_free_nnp
g_variant_valist_free_nnp does not take into account ^*ay, which causes
crash when trying to use these types together with
g_variant_iter_loop().
2018-10-31 18:38:11 +01:00
Tomasz Miąsko
54c394a73f gdatetime: Fix formatting of time zones offsets in range -01:00 to +00:00
Formatting code for `%z` specifier incorrectly assumed that sign of
offset from UTC can be recovered from the number of hours alone, which
is not true for offsets between -01:00 and +00:00.

Extract and format sign separately to avoid the problem.

Issue #1337.
2018-10-31 15:02:22 +01:00
Christian Persch
ae02adc3c3 gdatetime: Enable compile time check of g_date_time_format() format
By annotating it with G_GNUC_STRFTIME.

https://gitlab.gnome.org/GNOME/glib/issues/1575
2018-10-31 11:50:07 +01:00
Christian Persch
d62a07831c gmacros: Add G_GNUC_STRFTIME macro
Analogous to G_GNUC_PRINTF and G_GNUC_SCANF, to annotate
functions similar to strftime.

https://gitlab.gnome.org/GNOME/glib/issues/1575
2018-10-31 11:50:07 +01:00
Christophe Fergeau
7d1b94d71a test-gvariant: Add test for ^ay, ^&ay, ^aay, ^a&ay
This will exhibit bugs in g_variant_valist_free_nnp() as these types are
not properly handled.
2018-10-30 21:04:08 +01:00
Simon McVittie
4e058a698a meson: Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 on GNU/Linux if needed
armv5 Linux systems implement __sync_bool_compare_and_swap() and
friends by calling a function provided by the kernel. This is not
technically an atomic intrinsic, so gcc doesn't define
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 in this case, but it's good
enough for us. Extend the current Android special case to cover
GNU/Linux too.

The possibilities are:

* __sync_foo detected and __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 predefined:
  calls to __atomic_foo or __sync_foo primitives are inlined into user
  code by gatomic.h

* __sync_foo detected but __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not
  predefined: user code has an extern reference to g_atomic_foo(),
  which calls __atomic_foo or __sync_foo because we defined
  __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 when compiling GLib itself

* Windows: user code has an extern reference to g_atomic_foo(),
  which calls InterlockedFoo()

* !defined(G_ATOMIC_LOCK_FREE): user code has an extern reference to
  g_atomic_foo(), which emulates atomic operations with a mutex

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #1576
2018-10-30 17:20:43 +00:00