Commit Graph

3800 Commits

Author SHA1 Message Date
Philip Withnall
c9344fd513 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
2013-11-27 10:01:30 +00:00
Philip Withnall
32118951ea 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
2013-11-27 10:01:30 +00:00
Philip Withnall
c9ccc2af91 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
2013-11-27 10:01:29 +00:00
Philip Withnall
fe004445a4 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
2013-11-27 10:01:29 +00:00
Philip Withnall
73e6b900d4 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
2013-11-27 10:01:29 +00:00
Philip Withnall
8b9e8dc53b 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
2013-11-27 10:01:29 +00:00
Philip Withnall
aa28ced44e 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
2013-11-27 10:01:29 +00:00
Philip Withnall
956c58c7f2 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
2013-11-27 10:01:29 +00:00
Philip Withnall
c729f416fb 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
2013-11-27 10:01:29 +00:00
Philip Withnall
44af12aba1 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
2013-11-27 10:01:29 +00:00
Chun-wei Fan
b9322bf9ab 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
2013-11-27 08:01:47 +08:00
Michael Natterer
32cfcc8740 gio: remove precondition checks from g_output_stream_printf()
because we call g_output_stream_vprintf() which does exactly the same
checks.
2013-11-26 23:00:52 +01:00
Michael Natterer
d86396f21f gio: add g_output_string_[v]printf()
which are useful for porting FILE* based output code.
2013-11-26 11:51:24 +01:00
Chun-wei Fan
a997cfe90f 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
2013-11-26 13:16:15 +08:00
Colin Walters
03bf43e14a gsubprocess: Document g_subprocess_get_identifier() 2013-11-25 18:39:46 -05:00
Philip Withnall
299bcbfa41 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
2013-11-25 15:46:51 +00:00
Manuel Bachmann
1fb4b3b2bf 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.
2013-11-24 04:51:21 +01:00
Matthias Clasen
5efc038e0d 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
2013-11-23 22:24:51 -05:00
Matthias Clasen
0fc0754e65 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
2013-11-23 22:21:29 -05:00
Matthias Clasen
0250d185b1 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.
2013-11-23 21:28:40 -05:00
Christian Persch
bd8fb391aa application: Use printerr for runtime errors
g_critical can be fatal (with --g-fatal-warnings, or some env var set),
so don't use it to print out runtime errors.

Bug #676761.
2013-11-23 18:16:41 -05:00
Matthias Clasen
e45372895d Fix desktop-app-info test
The recent change to the search scoring algorithm made
nautilus and konqueror switch places in the search results.
Update the test to reflect that.
2013-11-23 18:15:04 -05:00
Stef Walter
baf92d09d6 gtestdbus: Properly close server connections
Otherwise g_test_dbus_down() following a g_test_dbus_stop()
will hang until it times out.

https://bugzilla.gnome.org/show_bug.cgi?id=711807
2013-11-23 17:37:58 -05:00
Stef Walter
5a5aaa203a gdbus-connection: Fix race condition in test
The test was expecting that the spawned process wouldn't start
up before the NameOwnerChanged signal was subscribed.

https://bugzilla.gnome.org/show_bug.cgi?id=711805
2013-11-23 15:20:51 -05:00
Lars Uebernickel
65da592249 Add basic test for the GNotification gtk backend
https://bugzilla.gnome.org/show_bug.cgi?id=711051
2013-11-23 15:11:09 -05:00
Stef Walter
797959f05a gtestdbus: Don't destroy GSource twice
https://bugzilla.gnome.org/show_bug.cgi?id=711806
2013-11-23 13:47:29 -05:00
Bastien Nocera
aef0adc0dd GSettings: More docs for deprecated _list_schemas()
Most _list_schemas() uses were to check for the availability
of a particular schema. g_settings_schema_source_lookup() is
a better way to do this.

https://bugzilla.gnome.org/show_bug.cgi?id=712315
2013-11-23 13:35:52 -05:00
Andrew Walton
4382e8b876 CLOEXEC fix for older FreeBSDs and OS X.
Some older POSIX-flavored operating systems may not have adopted
O_CLOEXEC yet.

See https://bugzilla.gnome.org/show_bug.cgi?id=712136.
2013-11-23 11:01:29 -05:00
Stef Walter
e3babb3687 giomodule: Allow overriding source directory gio modules are loaded from
When testing (and valgrinding) we need to have a known set of modules
loaded.

https://bugzilla.gnome.org/show_bug.cgi?id=711801
2013-11-23 01:17:03 -05:00
Dan Winship
8f5b40c046 gio/tests: fix output of gdbus-proxy-threads and gdbus-threading
Make gdbus-proxy-threads and gdbus-threading print a newline at the
end of their progress strings, to avoid messing up their TAP-format
output.

https://bugzilla.gnome.org/show_bug.cgi?id=711796
2013-11-23 00:43:54 -05:00
Dan Winship
c762a3a3f6 gio/tests: basic-application is a helper program, not a test
https://bugzilla.gnome.org/show_bug.cgi?id=711796
2013-11-23 00:43:53 -05:00
Dan Winship
158dde0507 Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.

Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:25:39 -05:00
Dan Winship
3981cddbf8 Require POSIX.1 (1990) compliance on unix
Assume unix platforms support the original POSIX.1 standard.
Specifically, assume that if G_OS_UNIX, then we have chown(),
getcwd(), getgrgid(), getpwuid(), link(), <grp.h>, <pwd.h>,
<sys/types.h>, <sys/uio.h>, <sys/wait.h>, and <unistd.h>.

Additionally, since all versions of Windows that we care about also
have <sys/types.h>, we can remove HAVE_SYS_TYPES_H checks everywhere.

Also remove one include of <sys/times.h>, and the corresponding
configure check, since the include is not currently needed (and may
always have just been a typo for <sys/time.h>).

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:17:42 -05:00
Dan Winship
6e4a7fca43 Require C90 compliance
Assume all supported platforms implement C90, and therefore they
(correctly) implement atexit(), memmove(), setlocale(), strerror(),
and vprintf(), and have <float.h> and <limits.h>.

(Also remove the configure check testing that "do ... while (0)" works
correctly; the non-do/while-based version of G_STMT_START and
G_STMT_END was removed years ago, but the check remained. Also, remove
some checks that configure.ac claimed were needed for libcharset, but
aren't actually used.)

Note that removing the g_memmove() function is not an ABI break even
on systems where g_memmove() was previously not a macro, because it
was never marked GLIB_AVAILABLE_IN_ALL or listed in glib.symbols, so
it would have been glib-internal since 2004.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:16:16 -05:00
Michael Haubenwallner
b1af471a3f build: Give internal libraries higher precedence
Linking local libraries too late may cause preinstalled libraries to
get found earlier, due to external library paths in .la files.

https://bugzilla.gnome.org/show_bug.cgi?id=712314
2013-11-19 08:11:35 -05:00
Colin Walters
a46459b000 GSocketClient: For _CONNECTING event, make remote address accessible
My application (hotssh) would like to get the resolved address from DNS,
before we start the connect().

We could add a new event, but it's easy enough to just cache it on the
GSocketConnection; this avoids any new API.

https://bugzilla.gnome.org/show_bug.cgi?id=712547
2013-11-18 17:13:34 -05:00
Michael Haubenwallner
efb1701bf3 Use AC_HEADER_MAJOR
Instead of checking for sys/mkdev.h headerfile, there is the
AC_HEADER_MAJOR helper for how to get major(), minor(), makedev().

https://bugzilla.gnome.org/show_bug.cgi?id=712314
2013-11-18 14:47:53 -05:00
Dan Winship
f79e39154d GDummyTlsBackend: cache the GDummyTlsDatabase
The default GTlsDatabase is supposed to be a singleton (and libsoup
has tests that will fail if it's not).
2013-11-17 09:45:20 -05:00
Ryan Lortie
ca830f2733 Fix GSettings testcase again
Hopefully this one will work for both srcdir == builddir and not.
2013-11-15 15:32:09 -05:00
Florian Müllner
2fb8901b64 gdesktopappinfo: Rank Keywords matches higher than GenericName
It makes sense to match on GenericName in case an application does
not provide any keywords, but the Keywords field has been added
to explicitly support the search case, while GenericName was used
to be displayed in menus, so it makes more sense to consider
Keywords more (or equally) relevant for search.

https://bugzilla.gnome.org/show_bug.cgi?id=711640
2013-11-13 16:54:02 +01:00
Ryan Lortie
ce35c08c57 Revert "gdbus-connection-loss: Fix leak in test"
This reverts commit 670379b26f.

This is causing distcheck to fail and will have to be revisited later.
2013-11-12 00:05:09 -05:00
Ryan Lortie
5c4f3f4dab gsettings test: fix srcdir != builddir
Just copy the schemas to the builddir and compile them in place instead
of trying to mess around with creating the compiled file in a different
dir.  This solves issues in the summary/description testcase when
GSettings expects the usual situation of having the .xml files present
in the same directory.
2013-11-12 00:05:04 -05:00
Stef Walter
1e5e3b64a8 gsubprocess: Fix a number of leaks and a segfault
Fixed a number of leaks in gsubprocess, as well as a segfault
that was hidden by never calling g_subprocess_communicate_state_free().

https://bugzilla.gnome.org/show_bug.cgi?id=711803
2013-11-11 17:41:39 +01:00
Stef Walter
a638be8a79 Revert "giomodule: Fix leaks in module loading"
This reverts commit dc72039c16.

This depends on a patch that allows GTypeModule to be finalized.
Lets put this back in bugzilla until that gets in.
2013-11-11 17:17:10 +01:00
Chun-wei Fan
0212ab6182 Tests: Fix up the expected messages
There was an expected messages that was not in the form that GLib on
Windows actually produces, which causes some test to fail.  Fix this up.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-11 22:40:57 +08:00
Chun-wei Fan
b27a2d436b gio/tests/gsubprocess.c: Fix on Windows
We need to check for the correct line endings on Windows (\r\n) for the
echo tests and currently need to skip the test_echo_eof test there, as
it depends on the cat utility that is not normally found on Windows, and
using an external installation of cat via MSYS or Cygwin would render the
test program to hang as cat waits for user input.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-11 22:38:05 +08:00
Dan Winship
fff14a5b7c gcancellable: don't use g_cancellable_connect() in GCancellableSource
g_cancellable_connect() is documented as calling its callback only
once, but GCancellableSource should trigger every time the cancellable
is cancelled.

https://bugzilla.gnome.org/show_bug.cgi?id=710691
https://bugzilla.gnome.org/show_bug.cgi?id=711286
2013-11-11 09:28:07 -05:00
Stef Walter
670379b26f gdbus-connection-loss: Fix leak in test
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 08:46:45 +01:00
Stef Walter
14b27eaab8 gdbus-introspection: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 08:46:33 +01:00
Stef Walter
dc72039c16 giomodule: Fix leaks in module loading
https://bugzilla.gnome.org/show_bug.cgi?id=711798
2013-11-11 07:22:48 +01:00