Without this, GNU-specific symbols won't be defined and the compiler
check will pass because GCC will assume that you know what you're
doing since it doesn't know what the symbol prototype is and compiler
checks aren't built with -Wall -Werror.
This will then cause a build failure because the wrong prototype will
be used.
Try to get XDG_* environment variables and, if they are available, use their
contents to initialize various directories the same way this happens on *nix.
When these variables are not available, fall back to the W32-specific APIs for
getting directories.
https://bugzilla.gnome.org/show_bug.cgi?id=766358
We use it pretty much everywhere in order to get feature detection, and
that's also what the AC_USE_SYSTEM_EXTENSIONS m4 macro defines in the
Autotools build.
https://bugzilla.gnome.org/show_bug.cgi?id=785955
Calling g_variant_get (parameters, "(&s)") when parameters has a
signature other than (s) is considered to be a programming error.
In practice the message bus (dbus-daemon or a reimplementation) should
always send the expected type, but be defensive.
(Modified by Philip Withnall to improve type check.)
Signed-off-by: Simon McVittie <smcv@collabora.com>
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=784392
PulseAudio and LibreOffice are among the services that use this flag.
Refusing to queue for a name lets you do this transaction,
but atomically, avoiding the transient state where you briefly join
the queue and then are given the name when its primary owner drops it:
result = RequestName(name)
if result == IN_QUEUE:
ReleaseName(name)
result = EXISTS
return result
(Modified by Philip Withnall to add documentation.)
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=784392
The implementation passes flags through directly to the RequestName()
call, so if any new values break that equivalence, the implementation
will have to be changed.
Signed-off-by: Simon McVittie <smcv@collabora.com>
https://bugzilla.gnome.org/show_bug.cgi?id=784392
If no callback is provided, token is never set, but it’s then passed to
g_variant_new_string(), which requires a non-NULL input.
Fix that by moving all the option handling inside the (callback != NULL)
case.
Spotted by Coverity (CID #1378714).
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=785817
Since --header --body has been deprecated and replaced with --body
--prototypes, the generated body is not wrapped with G_{BEGIN,END}_DECLS
any longer. Projects using C++ break due to that. Automatically wrap
prototypes individually in G_{BEGIN,END}_DECLS instead.
https://bugzilla.gnome.org/show_bug.cgi?id=785554
Little did I know when making commit
c257757cf6 that a lot of the output of
glib-compile-schemas is string matched in some of the unit tests. Fix
them to match the updated strings.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=695573
Some platforms use different extensions for compile-time linkable
libraries vs runtime-loadable modules. Need to use special libtool
flag in the latter case for consistency with what gmodule expects.
https://bugzilla.gnome.org/show_bug.cgi?id=731703
Instead of requiring --enable-compile-warnings or
--enable-compile-warnings=yes, allow any value which is not ‘no’. This
enables compile warnings for --enable-compile-warnings=maximum or
--enable-compile-warnings=error, which are common values for other GNOME
projects. While we don’t change our behaviour for [yes, maximum, error],
at least it means the warnings are enabled now, rather than disabled.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
• Fix capitalisation to be consistent
• Use Unicode quotation marks where appropriate
• Move trailing \n characters out of the translable strings and append
them unconditionally
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=695573
Mention that it really is a good idea to save errno before doing
literally anything else after calling a function which could set it.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=785577
Prevent the situation where errno is set by function A, then function B
is called (which is typically _(), but could be anything else) and it
overwrites errno, then errno is checked by the caller.
errno is a horrific API, and we need to be careful to save its value as
soon as a function call (which might set it) returns. i.e. Follow the
pattern:
int errsv, ret;
ret = some_call_which_might_set_errno ();
errsv = errno;
if (ret < 0)
puts (strerror (errsv));
This patch implements that pattern throughout GLib. There might be a few
places in the test code which still use errno directly. They should be
ported as necessary. It doesn’t modify all the call sites like this:
if (some_call_which_might_set_errno () && errno == ESOMETHING)
since the refactoring involved is probably more harmful than beneficial
there. It does, however, refactor other call sites regardless of whether
they were originally buggy.
https://bugzilla.gnome.org/show_bug.cgi?id=785577
The /etc/mtab file is still used by some distributions (e.g. Slackware),
so it has to be monitored instead of /proc/self/mountinfo in order to
avoid races between g_unix_mounts_get and "mounts-changed" signal. The
util-linux is built with --enable-libmount-support-mtab in that case and
mnt_has_regular_mtab is used for checks. Let's use mnt_has_regular_mtab
also to determine which file to monitor.
https://bugzilla.gnome.org/show_bug.cgi?id=779607
WaitForMultipleObjectsEx() returns the index of the *first* handle that triggered the wakeup, and promises that all handles with lower index are still inactive. Therefore, don't check them, only check the handles with higher index. This removes the need of rearranging the handles (and, now, handle_to_fd) array, it's enough to take a pointer to the next item and use it as a new, shorter array.
https://bugzilla.gnome.org/show_bug.cgi?id=785468
Put all ptrs for GPollFDs that contribute handles into an array, the layout of which mirrors the handles array. This way finding GPollFD for a handle is a simple matter of knowing this handle's index in the handles array (which is something we always know). Removes the need to loop through all fds looking for the right one. And, with the message FD also passed along, it's now completely unnecessary to even pass fds to poll_rest() at all.
https://bugzilla.gnome.org/show_bug.cgi?id=785468
Instead of just indicating that messages should be polled for, save the pointer to GPollFD that contains G_WIN32_MSG_HANDLE, and pass it along. This way it won't be necessary to loop through all fds later on, searching for G_WIN32_MSG_HANDLE.
https://bugzilla.gnome.org/show_bug.cgi?id=785468
WaitForSingleObjectEx() is supposed to be a more efficient sleep method.
It waits on the handle of the current process. That handle will be signaled once the process terminates, and since we're *inside* the process, it'll never happen (and if it does, we won't care anymore).
The use of an alertable wait ensures that we wake up when a completion routine wants to run.
https://bugzilla.gnome.org/show_bug.cgi?id=785468
The original ready < nhandles - 1 can be re-written as ready + 1 < nhandles
which is the same confition that we are checking on the first
itteration of the for loop. This means we can remove the if statement
and let the for loop check the code.
This also has the side effect of removing an invalid check as
WAIT_OBJECT_0 was not subtracted from ready in the if statement.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
It just creates a number of socket pairs, then triggers read-ready status on these pairs in different patterns (none, one, half, all) and checks how much time it takes to g_poll() those. Also sometimes posts a Windows message and polls for its arrival.
The g_main_context_new() is necessary to initialize g_poll() debugging on W32.
Measures minimal and maximal time it takes to g_poll(), as well as the average, over 1000 runs.
Collects the time values into 25 non-linear buckets between 0ns and 1000ns, and displays them at the conclusion of each subtest.
https://bugzilla.gnome.org/show_bug.cgi?id=785468
In case of Python 2 and stdout being redirected to a file, sys.stdout.encoding
is None and it defaults ASCII for encoding text.
To match the behaviour of Python 3, which uses the locale encoding also when
redirecting to a file, wrap sys.stdout with a StreamWriter using the
locale encoding.
https://bugzilla.gnome.org/show_bug.cgi?id=785113
GCC 6.3.1 thinks that tmp is being used uninitialized:
gdatetime.c: In function ‘format_ampm’:
gdatetime.c:2248:7: warning: ‘tmp’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
g_free (tmp);
^~~~~~~~~~~~
It is not an actual problem because the code in question is guarded by
"if (!locale_is_utf8)" and "#if defined (HAVE_LANGINFO_TIME)", and it
does get initialized under those circumstances. Still, it is a small
price to pay for a cleaner build and having actual problems stand out
more prominently.
https://bugzilla.gnome.org/show_bug.cgi?id=785438
Unlike g_application_register, there is no public API to unregister the
GApplication from D-Bus. Therefore, if the GApplication is set up
manually without using g_application_run, then neither can the
GApplicationImpl be destroyed nor can dbus_unregister be called before
destruction.
This is fine as long as no sub-class has implemented dbus_unregister.
If they have, their method method will be called after destruction, and
they should be prepared to deal with the consequences.
As long as there is no public API for unregistering, let's demote the
assertion to a WARNING. Bravehearts who don't use g_application_run
can continue to implement dbus_unregister, but they would have been
adequately notified.
This reverts commit c1ae1170fa.
https://bugzilla.gnome.org/show_bug.cgi?id=725950