Commit Graph

22423 Commits

Author SHA1 Message Date
Emmanuel Fleury
043cf25631 Fix missing initializer warnings in glib/tests/markup-subparser.c
In file included from glib/glib.h:60,
                 from glib/tests/markup-subparser.c:14:
glib/gmarkup.h:161:10: note: ‘text’ declared here
  161 |   void (*text)           (GMarkupParseContext *context,
      |          ^~~~
glib/tests/markup-subparser.c:335:3: error: missing initializer for field ‘error_message’ of ‘TestCase’
  335 |   { "<test/>",                  "<test></test>" },
      |   ^
glib/tests/markup-subparser.c:275:15: note: ‘error_message’ declared here
  275 |   const char *error_message;
      |               ^~~~~~~~~~~~~
glib/tests/markup-subparser.c:336:3: error: missing initializer for field ‘error_message’ of ‘TestCase’
  336 |   { "<sub><foo/></sub>",        "<sub><<{foo}{/foo}>></sub>" },
      |   ^
glib/tests/markup-subparser.c:275:15: note: ‘error_message’ declared here
  275 |   const char *error_message;
      |               ^~~~~~~~~~~~~
glib/tests/markup-subparser.c:337:3: error: missing initializer for field ‘error_message’ of ‘TestCase’
  337 |   { "<sub><foo/><bar/></sub>",  "<sub><<{foo}{/foo}{bar}{/bar}>></sub>" },
      |   ^
glib/tests/markup-subparser.c:275:15: note: ‘error_message’ declared here
  275 |   const char *error_message;
      |               ^~~~~~~~~~~~~
glib/tests/markup-subparser.c:338:3: error: missing initializer for field ‘error_message’ of ‘TestCase’
  338 |   { "<foo><bar/></foo>",        "<foo>[[{foo}{bar}{/bar}{/foo}]]</foo>" },
      |   ^
glib/tests/markup-subparser.c:275:15: note: ‘error_message’ declared here
  275 |   const char *error_message;
      |               ^~~~~~~~~~~~~
glib/tests/markup-subparser.c:339:3: error: missing initializer for field ‘error_message’ of ‘TestCase’
  339 |   { "<foo><x/><y/></foo>",      "<foo>[[{foo}{x}{/x}{y}{/y}{/foo}]]</foo>" },
      |   ^
glib/tests/markup-subparser.c:275:15: note: ‘error_message’ declared here
  275 |   const char *error_message;
      |               ^~~~~~~~~~~~~
glib/tests/markup-subparser.c:340:3: error: missing initializer for field ‘error_message’ of ‘TestCase’
  340 |   { "<foo/>",                   "<foo>[[{foo}{/foo}]]</foo>" },
      |   ^
glib/tests/markup-subparser.c:275:15: note: ‘error_message’ declared here
  275 |   const char *error_message;
      |               ^~~~~~~~~~~~~
glib/tests/markup-subparser.c:342:33: error: missing initializer for field ‘error_message’ of ‘TestCase’
  342 |                                 "<bar>[[{bar}{/bar}]]</bar>" }
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
glib/tests/markup-subparser.c:275:15: note: ‘error_message’ declared here
  275 |   const char *error_message;
      |               ^~~~~~~~~~~~~
2020-11-13 10:13:49 +01:00
Emmanuel Fleury
2eb66a2091 Fix missing initializer warning in glib/tests/markup-subparser.c
glib/tests/markup-subparser.c:269:1: error: missing initializer for field ‘text’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
  269 | };
      | ^
2020-11-13 10:13:49 +01:00
Emmanuel Fleury
7ea05283ac Fix signedness warnings in glib/tests/markup-subparser.c
glib/tests/markup-subparser.c: In function ‘main’:
glib/tests/markup-subparser.c:362:24: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  362 |          __add_tests_i < G_N_ELEMENTS (array);                          \
      |                        ^
glib/tests/markup-subparser.c:378:3: note: in expansion of macro ‘add_tests’
  378 |   add_tests (test, "/glib/markup/subparser/success", test_cases);
      |   ^~~~~~~~~
glib/tests/markup-subparser.c:362:24: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  362 |          __add_tests_i < G_N_ELEMENTS (array);                          \
      |                        ^
glib/tests/markup-subparser.c:379:3: note: in expansion of macro ‘add_tests’
  379 |   add_tests (test, "/glib/markup/subparser/failure", error_cases);
      |   ^~~~~~~~~
2020-11-13 10:13:49 +01:00
Emmanuel Fleury
24c60cee6c Fix missing initializer warnings in glib/tests/markup-collect.c
glib/gmarkup.h:154:10: note: ‘end_element’ declared here
  154 |   void (*end_element)    (GMarkupParseContext *context,
      |          ^~~~~~~~~~~
glib/tests/markup-collect.c:94:3: error: missing initializer for field ‘error_code’ of ‘struct test’
   94 |   { "<bool mb='false'/>", "<bool(1) 0 0 -1>" },
      |   ^
glib/tests/markup-collect.c:85:17: note: ‘error_code’ declared here
   85 |   GMarkupError  error_code;
      |                 ^~~~~~~~~~
glib/tests/markup-collect.c:95:3: error: missing initializer for field ‘error_code’ of ‘struct test’
   95 |   { "<bool mb='true'/>", "<bool(1) 1 0 -1>" },
      |   ^
glib/tests/markup-collect.c:85:17: note: ‘error_code’ declared here
   85 |   GMarkupError  error_code;
      |                 ^~~~~~~~~~
glib/tests/markup-collect.c:96:3: error: missing initializer for field ‘error_code’ of ‘struct test’
   96 |   { "<bool mb='t' ob='f' tri='1'/>", "<bool(1) 1 0 1>" },
      |   ^
glib/tests/markup-collect.c:85:17: note: ‘error_code’ declared here
   85 |   GMarkupError  error_code;
      |                 ^~~~~~~~~~
glib/tests/markup-collect.c:97:3: error: missing initializer for field ‘error_code’ of ‘struct test’
   97 |   { "<bool mb='y' ob='n' tri='0'/>", "<bool(1) 1 0 0>" },
      |   ^
glib/tests/markup-collect.c:85:17: note: ‘error_code’ declared here
   85 |   GMarkupError  error_code;
      |                 ^~~~~~~~~~
glib/tests/markup-collect.c:99:3: error: missing initializer for field ‘error_code’ of ‘struct test’
   99 |   { "<bool mb='y' my:attr='q'><my:tag/></bool>", "<bool(1) 1 0 -1>" },
      |   ^
glib/tests/markup-collect.c:85:17: note: ‘error_code’ declared here
   85 |   GMarkupError  error_code;
      |                 ^~~~~~~~~~
glib/tests/markup-collect.c💯3: error: missing initializer for field ‘error_code’ of ‘struct test’
  100 |   { "<bool mb='y' my:attr='q'><my:tag>some <b>text</b> is in here</my:tag></bool>", "<bool(1) 1 0 -1>" },
      |   ^
glib/tests/markup-collect.c:85:17: note: ‘error_code’ declared here
   85 |   GMarkupError  error_code;
      |                 ^~~~~~~~~~
glib/tests/markup-collect.c:111:3: error: missing initializer for field ‘error_code’ of ‘struct test’
  111 |   { "<str cm='x' am='y'/>", "<str(1) x y (null) (null)>" },
      |   ^
glib/tests/markup-collect.c:85:17: note: ‘error_code’ declared here
   85 |   GMarkupError  error_code;
      |                 ^~~~~~~~~~
2020-11-13 10:13:49 +01:00
Emmanuel Fleury
6c74ab7fcc Fix signedness warning in glib/tests/markup-collect.c
glib/gtestutils.h:134:96: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘GMarkupError’
  134 |                                                if (!err || (err)->domain != dom || (err)->code != c) \
      |                                                                                                ^~
glib/tests/markup-collect.c:168:7: note: in expansion of macro ‘g_assert_error’
  168 |       g_assert_error (error, G_MARKUP_ERROR, test->error_code);
      |       ^~~~~~~~~~~~~~
2020-11-13 10:13:49 +01:00
Emmanuel Fleury
93dd614562 Fixing missing initializer in glib/test/markup-collect.c
glib/tests/markup-collect.c:79:1: error: missing initializer for field ‘end_element’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
   79 | static GMarkupParser parser = { start };
      | ^~~~~~

glib/tests/markup-collect.c:198:1: error: missing initializer for field ‘end_element’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
  198 | };
      | ^
2020-11-13 10:13:49 +01:00
Emmanuel Fleury
2292960690 Fix signedness warning in glib/tests/spawn-multithreaded.c
glib/tests/spawn-multithreaded.c: In function ‘multithreaded_test_run’:
glib/tests/spawn-multithreaded.c:41:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’}
   41 |   for (i = 0; i < n_threads; i++)
      |                 ^
glib/tests/spawn-multithreaded.c:49:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’}
   49 |   for (i = 0; i < n_threads; i++)
      |                 ^
2020-11-13 10:13:49 +01:00
Emmanuel Fleury
0c81ed309e Fix missing initializer warnings in glib/tests/gvariant.c
glib/tests/gvariant.c: In function ‘test_lookup_value’:
glib/tests/gvariant.c:4353:5: error: missing initializer for field ‘value’ of ‘struct <anonymous>’
 4353 |     { "@a{ss} {'x':  'y'}",   "y"         },
      |     ^
glib/tests/gvariant.c:4350:31: note: ‘value’ declared here
 4350 |     const gchar *dict, *key, *value;
      |                               ^~~~~
glib/tests/gvariant.c:4355:5: error: missing initializer for field ‘value’ of ‘struct <anonymous>’
 4355 |     { "@a{os} {'/x': 'y'}",   "/y"        },
      |     ^
glib/tests/gvariant.c:4350:31: note: ‘value’ declared here
 4350 |     const gchar *dict, *key, *value;
      |                               ^~~~~
glib/tests/gvariant.c:4358:5: error: missing initializer for field ‘value’ of ‘struct <anonymous>’
 4358 |     { "@a{sv} {'x':  <'y'>}", "y"         }
      |     ^
glib/tests/gvariant.c:4350:31: note: ‘value’ declared here
 4350 |     const gchar *dict, *key, *value;
      |                               ^~~~~
2020-11-13 10:13:49 +01:00
Emmanuel Fleury
43a30e4983 Fix signedness warning in glib/test/tree.c
glib/tests/tree.c: In function ‘test_tree_traverse’:
glib/tests/tree.c:394:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  394 |   for (i = 0; i < G_N_ELEMENTS (orders); i++)
      |                 ^
2020-11-13 10:13:49 +01:00
Philip Withnall
a8bc604988 Merge branch 'string-precision-missing-link' into 'master'
Fix broken link syntax in g_vasprintf docs

See merge request GNOME/glib!1747
2020-11-12 17:01:01 +00:00
Michael McClurg
234a8cdea0 Fix broken link syntax in g_vasprintf 2020-11-12 03:25:58 +00:00
Philip Withnall
b8927cc6ad Merge branch 'wip/tingping/guri-normalize' into 'master'
guri: Normalize uri segments if they are encoded and add a flag to do scheme-based normalization

See merge request GNOME/glib!1716
2020-11-09 11:43:42 +00:00
Patrick Griffis
9da213ea34 docs: Add note about uri normalization for equality 2020-11-06 15:32:17 -06:00
Patrick Griffis
64f478dca3 guri: Add G_URI_FLAGS_SCHEME_NORMALIZE
This flag enables optional scheme-defined normalization
during parsing of a URI.
2020-11-06 15:32:17 -06:00
Philip Withnall
c1a11c02e5 Merge branch 'master' into 'master'
Add file handle support for gdbus call

Closes #961

See merge request GNOME/glib!1729
2020-11-06 17:19:28 +00:00
Norbert Pocs
a879c46a39 gdbus: Add FD support for gdbus call
Gdbus call could not take file handle (parameter 'h') as a parameter.

Original patch from Tim Waugh <twaugh@redhat.com>.

Fixes: #961
2020-11-06 17:19:27 +00:00
Patrick Griffis
482e10d3bb guri: Normalize uri segments if they are encoded
This changes it so when a segment is encoded it will be
normalized at parse time which ensures its valid and
it can more easily be compared with other uris.
2020-11-04 10:55:04 -06:00
Emmanuele Bassi
63dfceedd2 Merge branch 'scanner-undefined-behaviour' into 'master'
gscanner: Avoid undefined behaviour copying between union members

See merge request GNOME/glib!1737
2020-11-03 17:25:04 +00:00
Philip Withnall
add3be2086 gscanner: Avoid undefined behaviour copying between union members
It’s technically undefined behaviour in C to copy between two
potentially-overlapping regions of memory (just like it is when calling
`memcpy()`). This can easily happen with union members; and the ones in
`GScanner` in particular.

Fix that by copying through an intermediate variable.

Coverity CID: #1427317, 1427340

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-03 16:59:36 +00:00
Philip Withnall
e1e32e9b0b Merge branch 'wip/carlosg/shared-hidden-cache-timeout' into 'master'
glocalfileinfo: Use a single timeout source at a time for hidden file cache

See merge request GNOME/glib!1734
2020-11-03 15:09:44 +00:00
Carlos Garnacho
c1e0e6a055 glocalfileinfo: Use a single timeout source at a time for hidden file cache
As hidden file caches currently work, every look up on a directory caches
its .hidden file contents, and sets a 5s timeout to prune the directory
from the cache.

This creates a problem for usecases like Tracker Miners, which is in the
business of inspecting as many files as possible from as many directories
as possible in the shortest time possible. One timeout is created for each
directory, which possibly means gobbling thousands of entries in the hidden
file cache. This adds as many GSources to the glib worker thread, with the
involved CPU overhead in iterating those in its main context.

To fix this, use a unique timeout that will keep running until the cache
is empty. This will keep the overhead constant with many files/folders
being queried.
2020-11-03 14:16:36 +01:00
Philip Withnall
5719d2cde6 Merge branch 'wip/otte/interface-types' into 'master'
Improve support for interface types

See merge request GNOME/glib!1251
2020-11-02 18:07:29 +00:00
Matthias Clasen
0b1f909691 Add a test for signals returning interface types
Add a test for a signal returning interface types, using
the generic marshaller. This will hopefully exercise newly
added code in value_from_ffi_type().
2020-11-02 17:36:18 +00:00
Matthias Clasen
52357aac44 Add a binding test involving interfaces
This tests the new functionality that
g_type_interface_instantiable_prerequisite
was added for.

Before the changes, this fails with
GObject-WARNING **: Unable to convert a value of type \
                    GObject to a value of type Foo

We do the same test with g_object_bind_property_with_closures
as well, to exercise g_cclosure_marshal_generic.
2020-11-02 17:36:18 +00:00
Benjamin Otte
458e3b7a84 value: Allow automatic transforms to/from interfaces
Use the new g_type_interface_instantiable_prerequisite() to check
compatibility for transform functions.

In particular, this allows interfaces (in my case GDK_TYPE_PAINTABLE) to
be transformed to/from any GObject type (in my case G_TYPE_OBJECT) using
the transform function registered to transform between any 2 objects
(g_value_object_transform_value() does a type check and uses NULL if the
types don't match).

And this in turn allows be to g_object_bind_property() a gobject-typed
generic property (GtkListItem::item) to a GtkImage::paintable.

Tests for the new functionality are included.
2020-11-02 17:36:18 +00:00
Benjamin Otte
3f2a8d53f0 closure: Support generic marshals for interface returns
Use the newly added g_type_interface_instantiable_prerequisite() to
allow closure return values being interfaces by looking up the
instantiable type for the interface and using its GValue accessors.
2020-11-02 17:36:18 +00:00
Benjamin Otte
98f0a5a7da gtype: Add g_type_interface_instantiatable_prerequisite()
This function returns the most specific instantiatable type
that is a prerequisite for a given interface.

This type is necessary in particular when dealing with GValues
because a GValue contains an instance of a type.

This commit includes tests for the new API.
2020-11-02 17:36:18 +00:00
Benjamin Otte
e1b5afb7c0 gtype: Fix typo in API comment 2020-11-02 17:36:18 +00:00
Benjamin Otte
1f6c73747e Suggest braces around empty body in ‘if’ statements 2020-11-02 17:36:18 +00:00
Philip Withnall
86b910e6b1 Merge branch 'issue-2236' into 'master'
Include generated files and documentation in the GIO reference

Closes #2236

See merge request GNOME/glib!1730
2020-11-02 11:45:26 +00:00
Philip Withnall
f2e347d93a Merge branch 'wip/smcv/fileutils-test-as-root' into 'master'
glib/tests/fileutils: Fix expectations when running as root

See merge request GNOME/glib!1724
2020-11-02 11:18:49 +00:00
Philip Withnall
7fd0d1c762 Merge branch 'wip/smcv/assert-no-errno' into 'master'
Make more use of g_assert_no_errno()

See merge request GNOME/glib!1731
2020-11-02 11:16:25 +00:00
Simon McVittie
087fdf86a6 glib/tests/fileutils: Fix expectations when running as root
This test asserts that g_file_set_contents_full() will fail when used
on a read-only file, but processes with CAP_DAC_OVERRIDE on Linux or
uid 0 on traditional Unix can and do ignore DAC permissions.
See also #2027, #2028.

Bug-Debian: https://bugs.debian.org/973271
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-31 12:26:44 +00:00
Simon McVittie
f53aaeac9f gio/tests/gsettings: Assert that temporary directory ends up empty
If there are stray files left over, g_rmdir() will fail with ENOTEMPTY.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-31 12:26:01 +00:00
Simon McVittie
782c1b424e gio/tests/gsettings: Assert that g_chmod succeeds
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-31 12:24:59 +00:00
Simon McVittie
3f9f7da0f1 gio/tests/gsettings: Use g_assert_no_errno()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-31 12:24:22 +00:00
Simon McVittie
3468369625 gio/tests/appmonitor: Use g_assert_no_errno()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-31 12:24:05 +00:00
Simon McVittie
b3b4ad4f94 gio/tests/live-g-file: Use g_assert_no_errno()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-31 12:20:53 +00:00
Simon McVittie
c63da52bec glib/tests/fileutils: Make more use of g_assert_no_errno()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-31 12:20:32 +00:00
Emmanuele Bassi
e1744603d8 Build gdbus-objectmanager-example docs unconditionally
The GIO reference documentation links to that documentation, so we
cannot only build it when the installed tests are enabled.
2020-10-30 16:42:53 +00:00
Emmanuele Bassi
2993bb8275 docs: Fix xinclude directives
For legacy reasons, Meson's gtk-doc helper script launches the
gtkdoc-mkhtml tool in the `html` directory under the build root. This
means that all paths must be relative to that location.
2020-10-30 16:41:07 +00:00
Emmanuele Bassi
db2cb16e20 docs: Add missing annotation glossary
Without the glossary, gtk-doc will emit warnings for every introspection
annotation it finds.
2020-10-30 16:39:10 +00:00
Philip Withnall
b04a359d1e Merge branch 'mcatanzaro/#2233' into 'master'
gsocketclient: fix crash when async connection step fails

Closes #2233

See merge request GNOME/glib!1728
2020-10-28 16:04:22 +00:00
Michael Catanzaro
c2b8fa8a34 gsocketclient: fix crash when async connection step fails
This is a regression from !1686. The tmp_error is no longer valid after
it is "considered" and cannot be used at this point. We should print the
error earlier instead.

Fixes #2233
2020-10-28 10:43:43 -05:00
Philip Withnall
35ffbf953d Merge branch 'wip/smcv/big-dbus-write-with-fds' into 'master'
gdbus: Cope with sending fds in a message that takes multiple writes

Closes #2074

See merge request GNOME/glib!1725
2020-10-28 13:12:19 +00:00
Philip Withnall
5b0a7ed046 Merge branch 'wip/smcv/dbus-fd-convention' into 'master'
gdbus: Document the intended semantics of handles and fds

See merge request GNOME/glib!1726
2020-10-28 12:40:28 +00:00
Simon McVittie
e5cee9ce5a gio/tests/gdbus-peer: Exercise fds attached to a large message
This incidentally also exercises the intended pattern for sending fds in
a D-Bus message: the fd list is meant to contain exactly those fds that
are referenced by a handle (type 'h') in the body of the message, with
numeric handle value n corresponding to g_unix_fd_list_peek_fds(...)[n].

Being able to send and receive file descriptors that are not referenced by
a handle (as in OpenFile here) is a quirk of the GDBus API, and while it's
entirely possible in the wire protocol, other D-Bus implementations like
libdbus and sd-bus typically don't provide APIs that make this possible.

Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2074
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-28 12:03:59 +00:00
Simon McVittie
fc1f4969bf gdbus: Document the intended semantics of handles and fds
In the D-Bus wire protocol, the handle type (G_VARIANT_TYPE_HANDLE, h)
is intended to be an index/pointer into the implementation's closest
equivalent of GUnixFDList: its numeric value has no semantic meaning
(in the same way that the numeric values of pointers have no semantic
meaning), but a handle with value n acts as a reference to the nth fd
in the fd list.

GDBus provides a fairly direct mapping from the wire protocol to the
C API, which makes it technically possible to attach and use fds
without ever referring to them in the message body, and some
GLib-centric D-Bus APIs rely on this.

However, the other major implementations of D-Bus (libdbus and sd-bus)
transparently replace file descriptors with handles when building
messages, and transparently replace handles with file descriptors when
parsing messages. This means they cannot implement D-Bus APIs that do
not follow the conventional meaning of handles as indexes/pointers into
an equivalent of GUnixFDList.

For interoperability, we should encourage D-Bus API designers to follow
the convention, even though code written against GDBus doesn't strictly
need to do so.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-28 11:52:22 +00:00
Simon McVittie
70279f8446 gdbus: Cope with sending fds in a message that takes multiple writes
Suppose we are sending a 5K message with fds (so data->blob points
to 5K of data, data->blob_size is 5K, and fd_list is non-null), but
the kernel is only accepting up to 4K with each sendmsg().

The first time we get into write_message_continue_writing(),
data->total_written will be 0. We will try to write the entire message,
plus the attached file descriptors; or if the stream doesn't support
fd-passing (not a socket), we need to fail with
"Tried sending a file descriptor on unsupported stream".

Because the kernel didn't accept the entire message, we come back in.
This time, we won't enter the Unix-specific block that involves sending
fds, because now data->total_written is 4K, and it would be wrong to try
to attach the same fds again. However, we also need to avoid failing
with "Tried sending a file descriptor on unsupported stream" in this
case. We just want to write out the data of the rest of the message,
starting from (blob + total_written) (in this exaple, the last 1K).

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2074
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-28 11:06:52 +00:00
Philip Withnall
2d008e4645 Merge branch 'mcatanzaro/#2221' into 'master'
Fix race in socketclient-slow test

Closes #2221

See merge request GNOME/glib!1711
2020-10-26 15:40:49 +00:00