platform/upstream/glib.git
10 years agoSimplify subprocesses in tests
Matthias Clasen [Sun, 15 Dec 2013 16:20:19 +0000 (11:20 -0500)]
Simplify subprocesses in tests

Use the new way of running tests in a subprocess without
registering extra 'subprocess' test cases where appropriate.

10 years agogtestutils: Allow clean simple use of g_test_trap_subprocess()
Stef Walter [Wed, 11 Dec 2013 08:31:35 +0000 (09:31 +0100)]
gtestutils: Allow clean simple use of g_test_trap_subprocess()

Allow g_test_trap_subprocess() to be used in a simple cases by
rerunning the same test case itself. This is accomplished by
passing %NULL as the test case name.

https://bugzilla.gnome.org/show_bug.cgi?id=720236

10 years agoAdd a testcase for g_ptr_array_insert
Matthias Clasen [Sun, 15 Dec 2013 04:54:18 +0000 (23:54 -0500)]
Add a testcase for g_ptr_array_insert

10 years agoAdd g_ptr_array_insert to the docs
Matthias Clasen [Sun, 15 Dec 2013 04:45:36 +0000 (23:45 -0500)]
Add g_ptr_array_insert to the docs

10 years agoGPtrArray: Added g_ptr_array_insert()
Tristan Van Berkom [Wed, 27 Nov 2013 05:34:20 +0000 (14:34 +0900)]
GPtrArray: Added g_ptr_array_insert()

Speaks for itself, I've found myself on numerous occasions
writing my own version of this, or using a GArray of pointers.

https://bugzilla.gnome.org/show_bug.cgi?id=719395

10 years agoglib/gwin32.c: Silence a Deprecation Warning
Chun-wei Fan [Fri, 13 Dec 2013 08:21:00 +0000 (16:21 +0800)]
glib/gwin32.c: Silence a Deprecation Warning

Since we are already building a deprecated function for compatibility
reasons, we don't really need to see a warning when it uses another
deprecated GLib function.

10 years agogio/gdbusaddress: Clean up Win32 code a bit
Chun-wei Fan [Thu, 12 Dec 2013 10:00:52 +0000 (18:00 +0800)]
gio/gdbusaddress: Clean up Win32 code a bit

Combine duplicate parts into one, as the symbol used by RunDLL under x64
is the same for either Visual C++ or MinGW-64

10 years ago[l10n] Updated Italian translation.
Milo Casagrande [Thu, 12 Dec 2013 08:50:46 +0000 (09:50 +0100)]
[l10n] Updated Italian translation.

10 years agoRemove an unused define
Matthias Clasen [Wed, 11 Dec 2013 15:35:45 +0000 (10:35 -0500)]
Remove an unused define

https://bugzilla.gnome.org/show_bug.cgi?id=720210

10 years agogdesktopappinfo: Add missing annotations
Martin Pitt [Wed, 11 Dec 2013 12:17:10 +0000 (13:17 +0100)]
gdesktopappinfo: Add missing annotations

Add missing (allow-none) annotations to
g_desktop_app_info_launch_uris_as_manager(). Tested with

  python -c "from gi.repository import GLib, Gio; Gio.DesktopAppInfo.new('gcalctool.desktop').launch_uris_as_manager([], None, GLib.SpawnFlags.SEARCH_PATH|GLib.SpawnFlags.STDOUT_TO_DEV_NULL, None, None, None, None)"

which is necessary to do a launch_uris() without leaking stdout.

https://launchpad.net/bugs/1259721

10 years agoUpdate Visual C++ "Installation" Phase
Chun-wei Fan [Wed, 11 Dec 2013 12:09:59 +0000 (20:09 +0800)]
Update Visual C++ "Installation" Phase

Install the Python scripts that is used by gdbus-codegen in
share\glib-2.0\codegen, to be consistent with the other platforms.

Please see https://bugzilla.gnome.org/show_bug.cgi?id=702862 for details
on this.

10 years agogdbus-codegen: look for deps in correct path under win32
Manuel Bachmann [Wed, 11 Dec 2013 09:59:28 +0000 (10:59 +0100)]
gdbus-codegen: look for deps in correct path under win32

codegen.py and friends get installed in "share/glib-2.0",
so look for them there.

https://bugzilla.gnome.org/show_bug.cgi?id=702862

10 years agogdbus-connection: Work around race in connection tests
Stef Walter [Wed, 4 Dec 2013 11:48:53 +0000 (12:48 +0100)]
gdbus-connection: Work around race in connection tests

GDBusConnection cleanup is inherently racy due to its use of worker
threads. Put tests that expect a NULL G_BUS_TYPE_SESSION singleton
as the first tests to work around cleanup races.

https://bugzilla.gnome.org/show_bug.cgi?id=719837

10 years agog_get_current_dir(): consult PWD first
Ryan Lortie [Sun, 8 Dec 2013 23:18:16 +0000 (18:18 -0500)]
g_get_current_dir(): consult PWD first

Check if the current directory is the same as $PWD.  This matches the
behaviour of the get_current_dir_name() function in glibc.

https://bugzilla.gnome.org/show_bug.cgi?id=705902

10 years agog_settings_get: only check for non-copying format string
Lars Uebernickel [Sun, 8 Dec 2013 16:30:33 +0000 (17:30 +0100)]
g_settings_get: only check for non-copying format string

396d40af introduced a redundant call to g_variant_check_format_string().
Checking whether the format string copies all values is enough.

https://bugzilla.gnome.org/show_bug.cgi?id=719979

10 years agoclang fixes: tweak last commit
Ryan Lortie [Sun, 8 Dec 2013 21:38:47 +0000 (16:38 -0500)]
clang fixes: tweak last commit

We need to actually ignore "-Wformat-nonliteral" to make clang happy

10 years ago[PATCH] Fix trivial non literal format uses
Ryan Lortie [Sun, 8 Dec 2013 19:22:51 +0000 (14:22 -0500)]
[PATCH] Fix trivial non literal format uses

Based on a patch from Henrique Dante de Almeida <hdante@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=691608

10 years agoUpdate Chinese simplified translation
keyring [Sat, 7 Dec 2013 07:05:26 +0000 (15:05 +0800)]
Update Chinese simplified translation

10 years agog_settings_get: check validity of format string
Lars Uebernickel [Fri, 6 Dec 2013 15:01:48 +0000 (16:01 +0100)]
g_settings_get: check validity of format string

Allow only format strings that copy all values (i.e, don't contain '&'),
as the returned pointers might become invalid in some rare cases.

Since this is technically an API break, this patch only prints a
critical when a faulty format string is detected, but still fetches the
values.

https://bugzilla.gnome.org/show_bug.cgi?id=719979

10 years agogtestdbus: Add a note about thread safety to the documentation
Philip Withnall [Tue, 3 Dec 2013 08:27:05 +0000 (08:27 +0000)]
gtestdbus: Add a note about thread safety to the documentation

https://bugzilla.gnome.org/show_bug.cgi?id=712148

10 years agoFix documentation typos in GTask and GCancellable examples
Daiki Ueno [Thu, 5 Dec 2013 09:16:36 +0000 (18:16 +0900)]
Fix documentation typos in GTask and GCancellable examples

https://bugzilla.gnome.org/show_bug.cgi?id=719884

10 years agogsignal: Signal connection ids are always > 0 if successful
Colin Walters [Tue, 3 Dec 2013 22:15:14 +0000 (17:15 -0500)]
gsignal: Signal connection ids are always > 0 if successful

Note this explicitly so that people can rely on doing:

if (mystruct->sigid > 0)
  g_signal_disconnect (mystruct->object, mystruct->sigid);

https://bugzilla.gnome.org/show_bug.cgi?id=719809

10 years agogutf8: use g_try_malloc_n
Marc-André Lureau [Tue, 26 Nov 2013 16:45:37 +0000 (17:45 +0100)]
gutf8: use g_try_malloc_n

As recommended by Christian Persch.

https://bugzilla.gnome.org/show_bug.cgi?id=711546

10 years agogmessages: make _g_log_abort() do only breakpoints again
Marc-André Lureau [Tue, 3 Dec 2013 14:35:50 +0000 (15:35 +0100)]
gmessages: make _g_log_abort() do only breakpoints again

Commit e53caad4 makes _g_log_abort() noreturn by calling abort()
unconditionally.

However, it is useful to be able to skip some log_abort() with a
debugger, to reach a point of interest. Revert back to previous
behaviour. Make g_assert_warning() noreturn by calling abort().

https://bugzilla.gnome.org/show_bug.cgi?id=711800

10 years agoRemove g_trap_instance_signals as well
Matthias Clasen [Tue, 3 Dec 2013 03:26:48 +0000 (22:26 -0500)]
Remove g_trap_instance_signals as well

This is another crude conditional breakpoint mechanism and can
be done better with actual conditional breakpoints or with systemtap
tracepoints.

https://bugzilla.gnome.org/show_bug.cgi?id=719687

10 years agoDrop g_trap_object_ref debugging mechanism
Matthias Clasen [Tue, 3 Dec 2013 02:48:03 +0000 (21:48 -0500)]
Drop g_trap_object_ref debugging mechanism

This is really just a very crude and limited conditional breakpoint.
Update the documentation to explain conditional breakpoints in
gdb instead. Also, remove the link to refdbg, which appears dead.

https://bugzilla.gnome.org/show_bug.cgi?id=719687

10 years agoDocument clearly async functions not copying its args
Xavier Claessens [Mon, 2 Dec 2013 19:37:23 +0000 (14:37 -0500)]
Document clearly async functions not copying its args

Usually async methods copy/ref its arguments so caller can
forget about them. g_file_replace_contents_async() and
g_output_stream_write_async() are exceptions.

https://bugzilla.gnome.org/show_bug.cgi?id=690525

10 years agoGFile: add GBytes version of _replace_contents_async()
Xavier Claessens [Mon, 2 Dec 2013 19:40:35 +0000 (14:40 -0500)]
GFile: add GBytes version of _replace_contents_async()

https://bugzilla.gnome.org/show_bug.cgi?id=690525

10 years agogsubprocess: Annotate g_subprocess_newv()
Colin Walters [Sun, 1 Dec 2013 23:52:37 +0000 (18:52 -0500)]
gsubprocess: Annotate g_subprocess_newv()

So that it can actually be invoked by bindings.

10 years agobuild/win32/vs9/gio.vcprojin: Use UNIX Line endings
Chun-wei Fan [Mon, 2 Dec 2013 01:51:18 +0000 (09:51 +0800)]
build/win32/vs9/gio.vcprojin: Use UNIX Line endings

Be more consistent with the other project file templates, which will
simplify future application of patches.

10 years agoInstall all test data
Matthias Clasen [Sun, 1 Dec 2013 16:45:41 +0000 (11:45 -0500)]
Install all test data

The desktop-files directory contains a mimeapps.cache file
that was not installed as data for installed tests, causing
the file measure test to fail only in when installed.

10 years agoUpdated Lithuanian translation
Aurimas Černius [Sun, 1 Dec 2013 16:30:19 +0000 (18:30 +0200)]
Updated Lithuanian translation

10 years agoImprove file measure testcase
Matthias Clasen [Sun, 1 Dec 2013 03:51:03 +0000 (22:51 -0500)]
Improve file measure testcase

Make the testcase compare the byte size to what is reported
by du. Also add a test for the async api, and mak eit test
the progress reporting callback.

10 years agogtestdbus: Minor documentation fixes
Philip Withnall [Tue, 12 Nov 2013 13:14:19 +0000 (13:14 +0000)]
gtestdbus: Minor documentation fixes

https://bugzilla.gnome.org/show_bug.cgi?id=712148

10 years agogtestdbus: Fix non-const use of const variables
Philip Withnall [Tue, 12 Nov 2013 13:10:33 +0000 (13:10 +0000)]
gtestdbus: Fix non-const use of const variables

The argv array should be declared as const.

https://bugzilla.gnome.org/show_bug.cgi?id=712148

10 years agogtestdbus: Fix variable shadowing
Philip Withnall [Tue, 12 Nov 2013 13:09:56 +0000 (13:09 +0000)]
gtestdbus: Fix variable shadowing

Shut up, GCC.

https://bugzilla.gnome.org/show_bug.cgi?id=712148

10 years agoAdd a test for g_file_measure_disk_usage
Matthias Clasen [Fri, 29 Nov 2013 05:11:47 +0000 (00:11 -0500)]
Add a test for g_file_measure_disk_usage

10 years agotests/gsubprocess: Only compare basename of /tmp
Colin Walters [Fri, 29 Nov 2013 04:12:26 +0000 (04:12 +0000)]
tests/gsubprocess: Only compare basename of /tmp

Otherwise, we break in Continuous where /tmp == /sysroot/tmp,
and something in the execve() or the kernel will do realpath()
for us.

10 years agoImprove GType test coverage
Matthias Clasen [Fri, 29 Nov 2013 02:58:48 +0000 (21:58 -0500)]
Improve GType test coverage

Add a test for g_type_class_get_instance_private_offset

10 years agoAdd a test for g_atexit
Matthias Clasen [Fri, 29 Nov 2013 02:58:25 +0000 (21:58 -0500)]
Add a test for g_atexit

10 years agoImprove GApplication test coverage
Matthias Clasen [Fri, 29 Nov 2013 02:57:47 +0000 (21:57 -0500)]
Improve GApplication test coverage

Exercise more of the GActionMap implementation.

10 years agoImprove GNotification test coverage
Matthias Clasen [Fri, 29 Nov 2013 02:56:48 +0000 (21:56 -0500)]
Improve GNotification test coverage

10 years agoImprove GSimpleActionGroup test coverage
Matthias Clasen [Fri, 29 Nov 2013 02:53:53 +0000 (21:53 -0500)]
Improve GSimpleActionGroup test coverage

Add a case that overwrites an existing action.

10 years agoGenerate overview images for coverage
Matthias Clasen [Thu, 28 Nov 2013 19:50:59 +0000 (14:50 -0500)]
Generate overview images for coverage

lcov has the options to generate overview images for each source
file with the --frames option. Lets try this.

10 years agoImprove GSettings test coverage
Matthias Clasen [Thu, 28 Nov 2013 19:33:03 +0000 (14:33 -0500)]
Improve GSettings test coverage

This covers some more GSettingsSchemaKey api.

10 years agoImprove search utils test coverage
Matthias Clasen [Thu, 28 Nov 2013 18:54:50 +0000 (13:54 -0500)]
Improve search utils test coverage

This adds test cases for the Turkish i.

10 years agoImprove GNotification test coverage
Matthias Clasen [Thu, 28 Nov 2013 18:54:17 +0000 (13:54 -0500)]
Improve GNotification test coverage

10 years agoImprove GKeyFile test coverage
Matthias Clasen [Thu, 28 Nov 2013 18:00:03 +0000 (13:00 -0500)]
Improve GKeyFile test coverage

10 years agoImprove test coverage for GHashTable
Matthias Clasen [Thu, 28 Nov 2013 17:59:32 +0000 (12:59 -0500)]
Improve test coverage for GHashTable

10 years agoImprove test coverage for GSubprocess
Matthias Clasen [Thu, 28 Nov 2013 17:59:11 +0000 (12:59 -0500)]
Improve test coverage for GSubprocess

10 years agoImprove test coverage for gsettings
Matthias Clasen [Thu, 28 Nov 2013 17:58:44 +0000 (12:58 -0500)]
Improve test coverage for gsettings

10 years agoTest new gsettings api
Matthias Clasen [Thu, 28 Nov 2013 07:01:48 +0000 (02:01 -0500)]
Test new gsettings api

g_settings_get_user_value and g_settings_get_default_value
are now covered.

10 years agogio: Replace g_clear_object() with if()…g_object_unref()
Philip Withnall [Thu, 28 Nov 2013 20:41:49 +0000 (20:41 +0000)]
gio: Replace g_clear_object() with if()…g_object_unref()

As per https://bugzilla.gnome.org/show_bug.cgi?id=113075#c39.

10 years agogdbus-codegen: Fix leak in property setter
djcb [Thu, 28 Nov 2013 13:25:20 +0000 (08:25 -0500)]
gdbus-codegen: Fix leak in property setter

Comparing the code generated for the setter and other methods without
(real) return value, I noticed that the setter does not unref the
gvariant it gets.

https://bugzilla.gnome.org/show_bug.cgi?id=719472

10 years agoTest g_subprocess_launcher_spawn
Matthias Clasen [Thu, 28 Nov 2013 06:36:29 +0000 (01:36 -0500)]
Test g_subprocess_launcher_spawn

The spawnv variant of this function already had a test, but
spawn was not tested.

10 years agoFix g_subprocess_launcher_spawn
Matthias Clasen [Thu, 28 Nov 2013 06:34:52 +0000 (01:34 -0500)]
Fix g_subprocess_launcher_spawn

This function turns a varargs argument list into a string array,
but forgets to NULL-terminate it. This function was not covered
by unit tests...so it was broken.

10 years agoTest some more GSubProcess api
Matthias Clasen [Thu, 28 Nov 2013 06:12:26 +0000 (01:12 -0500)]
Test some more GSubProcess api

This covers g_subprocess_set_environ, g_subprocess_setenv,
g_subprocess_getenv, and g_subprocess_set_flags.

10 years agoAdd a GAppInfoMonitor test
Matthias Clasen [Thu, 28 Nov 2013 05:19:19 +0000 (00:19 -0500)]
Add a GAppInfoMonitor test

The test reveals that there's something fishy with this monitor.
One has to call g_app_info_get_all() for it to start working,
and then it only works once.

10 years agoAdd tests for new GAction api
Matthias Clasen [Thu, 28 Nov 2013 03:48:06 +0000 (22:48 -0500)]
Add tests for new GAction api

g_action_name_is_valid and g_action_parse_detailed_name are
now covered.

10 years agoFix g_win32_run_session_bus hook for MinGW-w64
Manuel Bachmann [Wed, 27 Nov 2013 22:18:54 +0000 (23:18 +0100)]
Fix g_win32_run_session_bus hook for MinGW-w64

On win64, g_win32_run_session_bus gets exported with this
precise name, with MinGW as well as MSVC.

Fixes annoying "Entry not found" UI warning.

10 years agogsettings tool: stop using GMainLoop
Ryan Lortie [Wed, 27 Nov 2013 17:41:33 +0000 (12:41 -0500)]
gsettings tool: stop using GMainLoop

Just iterate directly.

10 years agogsettings tool: fix some sed damage
Ryan Lortie [Wed, 27 Nov 2013 17:40:27 +0000 (12:40 -0500)]
gsettings tool: fix some sed damage

The previous patch to simplify the GSettings commandline tool by making
more use of global variables went a bit too far and broke 'gsettings
monitor' when used without a specific key.

Fix that up again.

10 years agoFix a warning about _g_log_abort()
Dan Winship [Wed, 27 Nov 2013 15:57:43 +0000 (10:57 -0500)]
Fix a warning about _g_log_abort()

G_BREAKPOINT is not noreturn, so make it so that we abort() if it
returns, to make _g_log_abort() be properly noreturn again.

10 years agoFix the gtestutils core dump prevention again
Dan Winship [Wed, 27 Nov 2013 15:15:44 +0000 (10:15 -0500)]
Fix the gtestutils core dump prevention again

The previous patch was preventing core dumps on failed assertions, but
not on g_error()s.

10 years agoGDBusObjectManagerClient: keep the manager alive while firing signals
Rui Matos [Wed, 27 Nov 2013 13:32:05 +0000 (14:32 +0100)]
GDBusObjectManagerClient: keep the manager alive while firing signals

Handlers for the signals we emit might unref the object manager. Make
sure we keep it alive until we are done with it.

https://bugzilla.gnome.org/show_bug.cgi?id=719402

10 years agotests: move /param/implement to -m slow
Ryan Lortie [Wed, 27 Nov 2013 15:13:10 +0000 (10:13 -0500)]
tests: move /param/implement to -m slow

Take this test out of 'make check'.  It's causing problems for a lot of people
due to fact that it's essentially a forkbomb.  It's causing failures for Debian
on ARM and it's DoSing coredumps to system crash collectors.

The conditional only covers registration of the master, not the
subprocess parts.  This is because g_test_slow() always return FALSE in
the subprocesses, so they would fail to run if we didn't register them
unconditionally.

10 years agogbytes: Clarify the nullability of GBytes->data
Philip Withnall [Mon, 25 Nov 2013 13:26:45 +0000 (13:26 +0000)]
gbytes: Clarify the nullability of GBytes->data

Clarify that it is permitted for a GBytes to contain a NULL data
pointer, as long as its size is 0.

https://bugzilla.gnome.org/show_bug.cgi?id=715164

10 years agogfileutils: Fix a potential integer overflow
Philip Withnall [Mon, 25 Nov 2013 14:06:01 +0000 (14:06 +0000)]
gfileutils: Fix a potential integer overflow

When calculating the array sizes in get_contents_stdio(), there is a
possibility of overflow for very large files. Rearrange the overflow
checks to avoid this.

The code already handled some possibilities of files being too large, so
no new GError has been added to handle this; the existing
G_FILE_ERROR_FAILED is re-used.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=715164

10 years agogvariant: Fix a potential memcpy(NULL) call
Philip Withnall [Mon, 25 Nov 2013 13:50:20 +0000 (13:50 +0000)]
gvariant: Fix a potential memcpy(NULL) call

This probably won’t crash, as it can only happen if (size == 0), but
add a check to be safe, and to shut up the static analyser.

This case can be reached with the following call:
    gvs_read_unaligned_le(NULL, 0)
which can be called from:
    gvs_tuple_get_child(value, index_)
with (value.data == NULL) and (value.size == 0).

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=715164

10 years agogio/tests: Add a dynamic type check assertion
Philip Withnall [Tue, 26 Nov 2013 11:21:37 +0000 (11:21 +0000)]
gio/tests: Add a dynamic type check assertion

This shuts up a static analysis false positive, and adds some extra
checking.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogio/tests: Add a non-NULL assertion to help static analysis
Philip Withnall [Tue, 26 Nov 2013 11:20:01 +0000 (11:20 +0000)]
gio/tests: Add a non-NULL assertion to help static analysis

The static analyser (correctly) considers a type check to fail if the
variable is NULL. In this case, the address must be non-NULL as no error
was thrown by g_socket_connection_get_remote_address(), but the static
analyser doesn’t know this.

Add a non-NULL assertion anyway, both to shut the analyser up, and
because it’s good extra testing.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogio/tests: Add non-NULL assertions to help static analysis
Philip Withnall [Tue, 26 Nov 2013 11:18:35 +0000 (11:18 +0000)]
gio/tests: Add non-NULL assertions to help static analysis

These prevent some false positives from the static analyser which are
caused by it not inspecting the invariants of
g_subprocess_communicate[_utf8]_finish() (i.e. that stdout and
stdout_str will always be set unless an error was returned).

They’re also good testing anyway.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogio/tests: Fix a g_return_val_if_fail() in a void function
Philip Withnall [Tue, 26 Nov 2013 11:18:01 +0000 (11:18 +0000)]
gio/tests: Fix a g_return_val_if_fail() in a void function

Should be g_return_if_fail() instead.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogunixmounts: Fix a potential strcmp(NULL) call
Philip Withnall [Tue, 26 Nov 2013 11:16:57 +0000 (11:16 +0000)]
gunixmounts: Fix a potential strcmp(NULL) call

mntent->mnt_fsname may be NULL at this point; if so, fall to the second
branch and set mount_entry->device_path = NULL.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogcontenttype: Fix a potential NULL pointer dereference
Philip Withnall [Tue, 26 Nov 2013 11:12:48 +0000 (11:12 +0000)]
gcontenttype: Fix a potential NULL pointer dereference

If the initial part of the header (‘MIME-TreeMagic’) is valid, but the
following line does not start with ‘[’ (i.e. is not a valid section
line), insert_matchlet() will be called with a NULL match pointer, and
will crash with a NULL pointer dereference.

Fix this by bailing out if a valid section line isn’t encountered before
the first insert_matchlet() call (i.e. between the header line and the
first data line).

Note that this has not been tested against a real treemagic file; the
fix is purely theoretical.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogunixfdlist: Fix a potential NULL pointer dereference
Philip Withnall [Tue, 26 Nov 2013 11:11:21 +0000 (11:11 +0000)]
gunixfdlist: Fix a potential NULL pointer dereference

In the case that (n_fds == 0 && fds == NULL), memcpy() would be called
against a NULL src pointer. Even though the number of bytes to copy is
0, avoid the possibility of a crash by only calling if fds is non-NULL.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogsocketaddress: Add an assertion to help static analysis
Philip Withnall [Tue, 26 Nov 2013 11:09:58 +0000 (11:09 +0000)]
gsocketaddress: Add an assertion to help static analysis

The static analyser will check dynamic type assertions and assume that
if they fail, the variable can either have the wrong type, or be NULL
(which is correct). The analyser doesn’t know that other constraints in
the API ensure the variable is non-NULL.

Add a non-null assertion to help the static analyser and shut it up in
this case.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogdbusserver: Fix a potential g_object_unref(NULL) call
Philip Withnall [Tue, 26 Nov 2013 11:08:50 +0000 (11:08 +0000)]
gdbusserver: Fix a potential g_object_unref(NULL) call

This can happen if the hash table lookup for ‘noncefile’ fails, and
hence the first ‘goto out’ is hit, at which point resolver is still
NULL.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogcontenttype: Fix a potential g_object_unref(NULL) call
Philip Withnall [Tue, 26 Nov 2013 11:07:45 +0000 (11:07 +0000)]
gcontenttype: Fix a potential g_object_unref(NULL) call

This can happen if the g_file_query_info() call fails, returning NULL.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075

10 years agogio/tests/memory-output-stream.c: Avoid an uninitialized variable
Chun-wei Fan [Fri, 15 Nov 2013 05:00:55 +0000 (13:00 +0800)]
gio/tests/memory-output-stream.c: Avoid an uninitialized variable

Be a little bit more careful in regards to initializing a primitive type
variable before passing it by reference, as it could have random stuff
in the variable's address depending on the CRT, such as MSVCR110.DLL,
causing random, invalid stuff being written in that address.

This will fix this test when built with Visual Studio 2012.

https://bugzilla.gnome.org/show_bug.cgi?id=711047

10 years agoglib/tests/enviroment.c: Fix running on Windows
Chun-wei Fan [Tue, 26 Nov 2013 10:57:04 +0000 (18:57 +0800)]
glib/tests/enviroment.c: Fix running on Windows

Don't attempt to insert environmental variables in the hash table during
the test listenv that is an empty string, as GetEnvironmentStringsW() also
returns special enviroment variables which have empty strings as their
variable names, at least on Windows 7 and 8.

https://bugzilla.gnome.org/show_bug.cgi?id=711047

10 years agogio: remove precondition checks from g_output_stream_printf()
Michael Natterer [Tue, 26 Nov 2013 22:00:52 +0000 (23:00 +0100)]
gio: remove precondition checks from g_output_stream_printf()

because we call g_output_stream_vprintf() which does exactly the same
checks.

10 years agogthread-posix: Don't use gslice allocated GRecMutex
Stef Walter [Thu, 31 Oct 2013 22:03:58 +0000 (23:03 +0100)]
gthread-posix: Don't use gslice allocated GRecMutex

This leads to problems during cleanup, and seems strange
to have locks defined in terms of things that need locking.

https://bugzilla.gnome.org/show_bug.cgi?id=711753

10 years agogio: add g_output_string_[v]printf()
Michael Natterer [Mon, 25 Nov 2013 22:26:21 +0000 (23:26 +0100)]
gio: add g_output_string_[v]printf()

which are useful for porting FILE* based output code.

10 years agogio/gdbusauthmechanismsha1.c: Move G_OS_* checks down
Chun-wei Fan [Tue, 26 Nov 2013 05:16:15 +0000 (13:16 +0800)]
gio/gdbusauthmechanismsha1.c: Move G_OS_* checks down

The G_OS_* checks are only valid if the GLib headers have been previously
included, so that io.h can be included properly on Windows

10 years agogsubprocess: Document g_subprocess_get_identifier()
Colin Walters [Mon, 25 Nov 2013 23:39:46 +0000 (18:39 -0500)]
gsubprocess: Document g_subprocess_get_identifier()

10 years agoUpdated Spanish translation
Daniel Mustieles [Mon, 25 Nov 2013 16:27:43 +0000 (17:27 +0100)]
Updated Spanish translation

10 years agogsubprocess: Fix potential strlen(NULL) calls
Philip Withnall [Mon, 25 Nov 2013 13:35:53 +0000 (13:35 +0000)]
gsubprocess: Fix potential strlen(NULL) calls

Also clarify the nullability of stdin_buf arguments in GSubprocess
communication calls.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=715164

10 years agoutf8: report allocation error
Marc-André Lureau [Wed, 6 Nov 2013 11:21:58 +0000 (12:21 +0100)]
utf8: report allocation error

Make some of the conversion functions a bit more friendly to allocation
failure.

Even though the glib policy is to abort() on allocation failure by
default, it can be quite helpful to return an allocation error for
functions already providing a GError.

I needed a safer g_utf16_to_utf8() to solve crash on big clipboard
operations with win32, related to rhbz#1017250 (and coming gdk handling
bug).

https://bugzilla.gnome.org/show_bug.cgi?id=711546

10 years agomsvc_recommended_pragmas.h: Treat C4819 warnings as errors
Chun-wei Fan [Mon, 25 Nov 2013 07:26:25 +0000 (15:26 +0800)]
msvc_recommended_pragmas.h: Treat C4819 warnings as errors

Warning C4819 in Visual Studio builds indicates an issue of Visual Studio
2005 and later running on East Asian locales of Windows, which likely
results in broken builds of GLib, Pango, GTK+, and possibly other GNOME
projects such as Cogl and Clutter (and is also an issue when building other
projects like QT and Firefox).

Treat this warning as an error as a result when building GLib-based items
on Visual Studio, and tell people how to remedy this issue correctly.

10 years agoReorganize the "don't dump core from test subprocesses" code.
Dan Winship [Sat, 23 Nov 2013 17:06:05 +0000 (12:06 -0500)]
Reorganize the "don't dump core from test subprocesses" code.

g_test_init() was calling _g_messages_set_exit_on_fatal() from
subprocesses, to make fatal log messages call _exit() rather than
abort(), but the function name is sort of confusing, and we don't
really need it anyway, since g_log() can just call g_test_subprocess()
instead and decide for itself.

Likewise, update g_assertion_message() to do the check itself, rather
than calling into gmessages to do it, and fix
g_assertion_message_expr() to also check whether it should exit or
abort. (Previously it always called abort(), although this didn't
actually matter since that was dead code until
test_nonfatal_assertions was added.)

https://bugzilla.gnome.org/show_bug.cgi?id=711800

10 years agogtestutils: add g_assert_nonnull() to go with g_assert_null()
Dan Winship [Sun, 10 Nov 2013 20:27:26 +0000 (15:27 -0500)]
gtestutils: add g_assert_nonnull() to go with g_assert_null()

https://bugzilla.gnome.org/show_bug.cgi?id=711800

10 years agogtestutils: fix g_test_set_nonfatal_assertions()
Dan Winship [Sun, 10 Nov 2013 20:44:06 +0000 (15:44 -0500)]
gtestutils: fix g_test_set_nonfatal_assertions()

g_test_set_nonfatal_assertions() was a no-op, because
g_assertion_message() wasn't actually checking the
test_nonfatal_assertions flag. Fix that and add a test.

Also, g_test_set_nonfatal_assertions() has to set test_mode_fatal to
FALSE as well, or else a failed assertion will cause the test program
to abort at the end of the failed test.

Also, belatedly add this and the new g_assert_* methods to the docs.

https://bugzilla.gnome.org/show_bug.cgi?id=711800

10 years agoAdd boolean returns to some hash functions
Matthias Clasen [Sun, 24 Nov 2013 06:22:44 +0000 (01:22 -0500)]
Add boolean returns to some hash functions

The functions g_hash_table_insert, g_hash_table_replace
and g_hash_table_add now return TRUE if they inserted a
new key/value pair.

https://bugzilla.gnome.org/show_bug.cgi?id=697828

10 years agoAvoid a compiler warning
Matthias Clasen [Sun, 24 Nov 2013 05:56:26 +0000 (00:56 -0500)]
Avoid a compiler warning

10 years agoFix G_OS #ifdefs in gbusserver.c
Manuel Bachmann [Sun, 24 Nov 2013 03:51:21 +0000 (04:51 +0100)]
Fix G_OS #ifdefs in gbusserver.c

G_OS #ifdefs are only available once glibconfig.h has been
evaluated ; that is, after including glib headers.
Move this block down so it gets correctly evaluated.

10 years agoFix up appinfo test
Matthias Clasen [Sun, 24 Nov 2013 03:24:00 +0000 (22:24 -0500)]
Fix up appinfo test

Make it possible to skip the terminal-launching test simply
by setting DISPLAY= . Previously, you had to unset DISPLAY,
which is a little more cumbersome.

https://bugzilla.gnome.org/show_bug.cgi?id=711178

10 years agoFix up the appinfo test
Matthias Clasen [Sun, 24 Nov 2013 03:21:29 +0000 (22:21 -0500)]
Fix up the appinfo test

One testcase was launching appinfo-test from a GAppInfo that
does not have a filename. In this case, the G_LAUNCHED_DESKTOP_FILE
envvar is not exported. Make appinfo-test deal with that, without
spewing warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=711178

10 years agoFix warnings in a the actions test
Matthias Clasen [Sun, 24 Nov 2013 02:28:40 +0000 (21:28 -0500)]
Fix warnings in a the actions test

The actions test tests the GSimpleActionGroup API. Maybe this
should be moved to use GActionMap, but for now, just disable
the deprecations.

There was also one test that wasn't actually hooked up, so
do that as well.

10 years agoFix array API inconsistency
Matthias Clasen [Sun, 24 Nov 2013 02:10:06 +0000 (21:10 -0500)]
Fix array API inconsistency

g_array_remove_range and g_byte_array_remove_range return
a pointer to the array, g_ptr_array_remove_range returns
void. Since it is pretty harmless, make it return the array
too.

https://bugzilla.gnome.org/show_bug.cgi?id=159528