gio/tests: Add a non-NULL assertion to help static analysis
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 26 Nov 2013 11:20:01 +0000 (11:20 +0000)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 27 Nov 2013 10:01:30 +0000 (10:01 +0000)
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

gio/tests/proxy-test.c

index ad2fcdf451892eaa42d5c35f7da061dc4b337d39..af91f382ebc8ca485793363029170ade317f9c65 100644 (file)
@@ -889,7 +889,7 @@ assert_direct (GSocketConnection *conn)
 
   addr = g_socket_connection_get_remote_address (conn, &error);
   g_assert_no_error (error);
-  g_assert (!G_IS_PROXY_ADDRESS (addr));
+  g_assert (addr != NULL && !G_IS_PROXY_ADDRESS (addr));
   g_object_unref (addr);
 
   addr = g_socket_connection_get_local_address (conn, &error);