Commit Graph

20616 Commits

Author SHA1 Message Date
Philip Withnall
1e10d6b6dd glib-genmarshal: Avoid a string copy for static string valist arguments
When building a valist marshaller, we can avoid a string copy if the
argument is known to always be static. The marshaller we ship in
`gmarshal.c` got this right, but marshallers generated by
glib-genmarshal were missing the optimisation. Fix that, and add a unit
test.

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

Fixes: #1792
2019-06-08 00:31:03 +01:00
Philip Withnall
f044ddc1ee glib-genmarshal: Fix ref-sinking of GVariants in valist marshallers
The old (Perl) implementation of glib-genmarshal used
g_variant_ref_sink() to correctly handle floating inputs; the Python
version should do the same.

Includes a unit test.

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

Fixes: #1793
2019-06-08 00:30:59 +01:00
Philip Withnall
e34839f8f4 tests: Add basic test for glib-genmarshal
This is a basic test suite for the `glib-genmarshal` utility, lifted
mostly directly from the tests for `glib-mkenums`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-08 00:11:13 +01:00
Philip Withnall
e3171ee08c build: Add installed-tests support for mkenums.py
This makes the Meson build code for it a little more generic, and adds
support for installed tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-08 00:11:13 +01:00
Philip Withnall
3f02660ea5 tests: Fix hard-coded install path in glib-mkenums test
While this was useful for local testing while developing the test, it’s
not widely applicable. Look the binary up in the current `${PATH}` if
it’s not specified using `G_TEST_BUILDDIR`.

This is needed to get the `mkenums.py` test working as an
installed-test.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-08 00:11:13 +01:00
Philip Withnall
71973c722a gmain: Clarify that g_source_destroy() doesn’t drop a reference
This always confuses people.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-07 11:26:47 +01:00
Philip Withnall
4e00fdea9b Merge branch 'filio' into 'master'
Include <sys/filio.h> for FIONREAD

See merge request GNOME/glib!889
2019-06-05 11:24:56 +00:00
Philip Withnall
973406ab58 Merge branch 'dboles/atomit' into 'master'
garcbox.c: Fix typo atomit => atomic

See merge request GNOME/glib!884
2019-06-04 19:50:41 +00:00
Philip Withnall
032d275e21 Merge branch 'wip/desrt/happier-eyeballs' into 'master'
gnetworkaddress: fix "happy eyeballs" logic

See merge request GNOME/glib!865
2019-06-04 19:45:48 +00:00
Philip Withnall
2ac3cf8222 Merge branch 'issue-737' into 'master'
Allow calling get_property() with an uninitialized GValue

Closes #737

See merge request GNOME/glib!892
2019-06-04 19:35:53 +00:00
Philip Withnall
fc59d3ee3d Merge branch 'fix-glib-win32-test' into 'master'
glib/tests/win32.c: Fix test variable types

Closes #1797

See merge request GNOME/glib!891
2019-06-04 19:26:45 +00:00
Allison Karlitskaya
efeaf8f747 network-address test: add ipv6-fail ipv4-slow case
Add a case for when the IPv6 result comes back negative and the IPv4
result is significantly delayed.  This is exactly the case that causes
the bug addressed by GNOME/glib!865
2019-06-04 20:09:26 +01:00
Allison Karlitskaya
97f8d3e1d8 gnetworkaddress: fix "happy eyeballs" logic
The "happy eyeballs" RFC states that on receiving a negative response
for an IPv6 address lookup, we should wait for the IPv4 lookup to
complete and use any results we get from there.

The current code was not doing that: it was rather setting a timeout for
failing the resolution entirely.  In scenarios where the IPv4 response
comes more than 50ms after the IPv6 response (which is easily attainable
under valgrind in certain configurations) this means that the IPv4
response will never come.

Remove the timeout and just wait.

See merge request GNOME/glib!865
2019-06-04 20:09:26 +01:00
Daniel Boles
c9b255f6c6 garcbox.c: Fix typo atomit => atomic 2019-06-04 20:08:46 +01:00
Chun-wei Fan
5e0f384f88 glib/tests/win32.c: Fix test variable types
The variable types for the PID (bp) and event (be) are accidentally
reversed in the test program.  Correct their types so that tests do not
fail on Visual Studio x64 builds.

Fixes issue #1797
2019-06-04 20:08:20 +01:00
Emmanuele Bassi
56a56f1ee5 Allow calling get_property() with an uninitialized GValue
We already have the GType with which the GValue should be initialized,
so requiring an initialized GValue is not really necessary, and it
actually complicates code that wraps GObject, by requiring the retrieval
of the GParamSpec in order to get the property type. Additionally, it
introduces a mostly unnecessary g_value_reset().

We already changed g_object_getv() to allow passing uninitialized
GValues, but this fell through the cracks.

Closes: #737
2019-06-04 20:05:24 +01:00
Philip Withnall
0bb8ada1f5 Merge branch 'freebsd-gunichar-wchart-fixes' into 'master'
gunicollate: work around FreeBSD wchar_t not matching our gunichar type

Closes #1798

See merge request GNOME/glib!893
2019-06-04 18:56:09 +00:00
Christoph Reiter
b49e767e2e gunicollate: work around FreeBSD wchar_t not matching our gunichar type
In !863 I assumed that a 4 byte wchar_t would be equal to gunichar on all platforms,
but this is not the case for FreeBSD. It previously was using the non wchar_t based API
because it doesn't define __STDC_ISO_10646__.

Add back the __STDC_ISO_10646__ check again and introduce a more meaningful macro for guarding
the code paths that are mixing gunichar and wchar_t.

Fixes #1798
2019-06-04 18:20:18 +02:00
Maya Rashish
de2ad60578 Include <sys/filio.h> for FIONREAD 2019-06-04 13:13:37 +03:00
Philip Withnall
b73713d893 tests: Add a test for g_content_type_guess() with no arguments
It should produce a generic result, but not crash. It was previously
crashing on macOS.

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

Fixes: #1729
2019-06-03 12:16:50 +01:00
Philip Withnall
4a0cb8f3a1 xdgmime: Don’t set an out argument if it’s NULL
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1729
2019-06-03 12:13:53 +01:00
Philip Withnall
d586ab4c73 tests: Use g_assert_*() instead of g_assert() in contenttype tests
g_assert_*() give more helpful error messages on failure, and aren’t
compiled out by G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-03 12:13:53 +01:00
Sebastian Dröge
41f68f8b19 Merge branch '590-rwlock-docs' into 'master'
gthread: Fix g_rw_lock_reader_lock() documentation

Closes #590

See merge request GNOME/glib!882
2019-06-03 10:44:32 +00:00
Sebastian Dröge
a4d01fcd4b Merge branch '1796-gio-pkg-bin-variables' into 'master'
build: Add various installed utilities to gio-2.0.pc

Closes #1796

See merge request GNOME/glib!881
2019-06-03 10:43:44 +00:00
Emmanuele Bassi
17880eb8e0 Merge branch 'option-docs' into 'master'
goption: Clarify G_OPTION_ARG_FILENAME documentation

See merge request GNOME/glib!885
2019-06-03 10:41:13 +00:00
Sebastian Dröge
645dcc232c Merge branch 'gsubprocess-test-fix' into 'master'
tests: Fix small race in GSubprocess tests

See merge request GNOME/glib!883
2019-06-03 10:39:26 +00:00
Philip Withnall
e1992a0e0e goption: Clarify G_OPTION_ARG_FILENAME documentation
It’s already documented elsewhere, but not particularly obviously.
Clarify argument encodings in the GOptionArg documentation.

As reported on StackOverflow:
https://stackoverflow.com/q/56416098/2931197.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-03 10:57:18 +01:00
Balázs Úr
2d16ec8545 Update Hungarian translation 2019-06-01 15:41:51 +00:00
Philip Withnall
799caf772b gsubprocess: Add missing (nullable) annotation to get_identifier()
The bottom of the documentation comment for this symbol seems to have
been missing.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 23:38:58 +01:00
Philip Withnall
7f256e63d0 tests: Fix small race in GSubprocess tests
This was introduced in commit 7846d6154a: g_subprocess_get_identifier()
will return NULL after the subprocess has exited, and the subprocess in
the `noop` test will exit as soon as it has started spawning. So if the
scheduler scheduled the testprog subprocess quickly, descheduled the
parent test process until the testprog exited, then the return value
from g_subprocess_get_identifier() would be NULL.

Move the g_subprocess_get_identifier() test to one which calls testprog
in `sleep-forever` mode, since that is guaranteed not to exit until
killed (which we do later in the test).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 23:35:27 +01:00
Philip Withnall
231661e46c gthread: Fix g_rw_lock_reader_lock() documentation
The documentation erroneously said that a thread calling
g_rw_lock_reader_lock() would always block if another thread was waiting
for the write lock. That’s not true: if no thread holds the lock, it is
implementation defined which of a waiting reader and writer gets the
lock.

See
http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_rwlock_rdlock.html.

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

Fixes: #590
2019-05-31 21:36:34 +01:00
Philip Withnall
3a9f9e3509 build: Add various installed utilities to gio-2.0.pc
The most useful ones were already listed in the pkg-config file, but
some others (notably, `gio-querymodules`) were not. List them in the
pkg-config file with their installed paths so that the right binary is
used if GIO is installed in a non-default path.

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

Fixes: #1796
2019-05-31 21:23:05 +01:00
Michael Catanzaro
e6a55def7d Merge branch '1788-network-more-reachable' into 'master'
gnetworkmonitornm: Consider NM_STATE_CONNECTED_SITE to be available

Closes #1788

See merge request GNOME/glib!880
2019-05-31 14:44:44 +00:00
Philip Withnall
e37f0cbd89 gnetworkmonitornm: Consider NM_STATE_CONNECTED_SITE to be available
`NM_STATE_CONNECTED_SITE` is documented to mean that a default route is
available, but that the internet connectivity check failed. A default
route being available is compatible with the documentation for
GNetworkMonitor:network-available, which should be true if the system
has a default route for at least one of IPv4 and IPv6.

https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html

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

Fixes: #1788
2019-05-31 11:19:07 +01:00
Sebastian Dröge
8b3f186d8f Merge branch '1790-file-attribute-as-string-annotation' into 'master'
gfileinfo: Add missing (nullable) annotation to get_attribute_as_string()

Closes #1790

See merge request GNOME/glib!879
2019-05-31 10:16:43 +00:00
Sebastian Dröge
c1a15894e4 Merge branch 'writev-max-num-vectors' into 'master'
Clamp number of vectors to IOV_MAX / UIO_MAXIOV for GOutputStream writev()...

See merge request GNOME/glib!874
2019-05-31 10:04:57 +00:00
Philip Withnall
ebacb64539 gfileinfo: Slightly improve documentation formatting
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 10:58:10 +01:00
Philip Withnall
67a0d5237e gfileinfo: Add missing (nullable) annotation to get_attribute_as_string()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1790
2019-05-31 10:58:00 +01:00
Sebastian Dröge
20a2c379c4 Clamp number of vectors to IOV_MAX / UIO_MAXIOV for GOutputStream writev() calls in the implementations
More vectors will give an error and we can simply clamp here and
consider it like a short write instead.

In case of GSocketOutputStream this is done here instead of inside
GSocket before calling sendmsg() because we we can't generically handle
short writes when sending messages on a socket, e.g. for datagram
sockets this causes only part of the datagram to be sent and an error
would be more useful in this case than sending corrupted data.

Also reduce the fallback limit to 16 in gsocket.c as that's the minimum
value required by POSIX and add a static assertion that the limit is
never bigger than G_MAXINT as that's the type recvmmsg/sendmmsg take.
2019-05-31 12:51:59 +03:00
Philip Withnall
947355c101 Merge branch 'wip/oholy/copy-permissions' into 'master'
CVE-2019-12450: gfile: Limit access to files when copying

See merge request GNOME/glib!876
2019-05-31 09:09:30 +00:00
Philip Withnall
57a1d79361 Merge branch 'source-atomic-refcounting-only' into 'master'
Use atomic reference counting for GSource

See merge request GNOME/glib!873
2019-05-30 12:34:17 +00:00
Philip Withnall
40ff475977 Annotate various types and macros as deprecated
These have all been documented as deprecated for a long time, but we’ve
never had a way to programmatically mark them as deprecated. Do that
now.

This is based on the list of deprecations from the reverted commit
80fcb1bc2.

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

Fixes: #638
2019-05-30 10:39:11 +01:00
Philip Withnall
1741fc2c6e build: Drop use of G_DISABLE_DEPRECATED from the build system
It’s no longer used in any of the headers. See preceding commits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
99b412bb19 gdate: Drop unnecessary use of G_DISABLE_DEPRECATED
The function is already annotated with `GLIB_DEPRECATED_FOR()`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
e62e89f2f8 Fix various deprecation warnings in code and tests
This code uses, or tests, deprecated functions, types or macros; so
needs to be compiled with deprecation warnings disabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
f0fb7b77a1 glib, gobject: Annotate deprecated types and enumerators
Use the new `GLIB_DEPRECATED_{TYPE,ENUMERATOR}*` macros to annotate types
and enumerators as deprecated, rather than using `G_DISABLE_DEPRECATED`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
6554c91b13 gutils: Move g_ATEXIT() and g_memmove() definitions from glibconfig.h
The definitions weren’t templated in glibconfig.h.in at all, so didn’t
vary between configurations of GLib — so they should be in a normal
header.

Move them to gutils.h and fix the deprecation annotations.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
74ca348e99 glib: Unconditionally include deprecated headers
This allows the symbols there to be used conditionally, depending on the
user’s stated `GLIB_VERSION_MIN_REQUIRED` and `GLIB_VERSION_MAX_ALLOWED`
preferences.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
b4d58a7105 glib, gio: Use GLIB_DEPRECATED_MACRO instead of G_DISABLE_DEPRECATED
When defining deprecated macros, annotate them with
`GLIB_DEPRECATED_MACRO_IN_*()` and `GLIB_DEPRECATED_MACRO_IN_*_FOR()` to
conditionally emit warnings if people use them, depending on their
declared minimum and maximum GLib version requirements (see
`GLIB_VERSION_MIN_REQUIRED` and `GLIB_VERSION_MAX_ALLOWED`).

The old way of doing this was for users to define `G_DISABLE_DEPRECATED`
if they didn’t want to use deprecated APIs, but it reported errors via
missing symbols, and wasn’t version-dependent. It’s being phased out.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
db270e3c2d gmacros: Add GLIB_DEPRECATED_{MACRO,ENUMERATOR,TYPE}{,_FOR}
These will be used to annotate deprecated macros, types and enumerators.

`GLIB_DEPRECATED_MACRO{,_FOR}` are based very heavily on the
corresponding macros from Clutter, written by Emmanuele Bassi.

The other deprecation annotators use the standard annotations supported
by Clang and GCC. They need to be separated as they are supported in
different versions of the compilers.

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

Fixes: #1060
2019-05-30 10:38:45 +01:00