Commit 9ef23947 authored by Thomas Haller's avatar Thomas Haller

all: fix various warnings detected with coverity

https://bugzilla.gnome.org/show_bug.cgi?id=728320Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
parent 981e33b8
......@@ -699,7 +699,7 @@ parse_output_fields (const char *fields_str,
if (found) {
/* Add index to array, and field name (or NULL) to group_fields array */
g_array_append_val (array, idx);
if (*group_fields)
if (group_fields && *group_fields)
g_ptr_array_add (*group_fields, g_strdup (right));
}
if (right)
......
......@@ -402,11 +402,8 @@ out:
if (slot)
PK11_FreeSlot (slot);
if (padded_buf) {
memset (padded_buf, 0, padded_buf_len);
g_free (padded_buf);
padded_buf = NULL;
}
memset (padded_buf, 0, padded_buf_len);
g_free (padded_buf);
if (!success) {
memset (output, 0, output_len);
......
......@@ -492,8 +492,6 @@ nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *setting,
}
copy = nm_ip4_address_dup (address);
g_return_val_if_fail (copy != NULL, FALSE);
priv->addresses = g_slist_append (priv->addresses, copy);
priv->address_labels = g_slist_append (priv->address_labels, g_strdup (label));
......@@ -645,8 +643,6 @@ nm_setting_ip4_config_add_route (NMSettingIP4Config *setting,
}
copy = nm_ip4_route_dup (route);
g_return_val_if_fail (copy != NULL, FALSE);
priv->routes = g_slist_append (priv->routes, copy);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ROUTES);
return TRUE;
......
......@@ -490,8 +490,6 @@ nm_setting_ip6_config_add_address (NMSettingIP6Config *setting,
}
copy = nm_ip6_address_dup (address);
g_return_val_if_fail (copy != NULL, FALSE);
priv->addresses = g_slist_append (priv->addresses, copy);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ADDRESSES);
return TRUE;
......@@ -633,8 +631,6 @@ nm_setting_ip6_config_add_route (NMSettingIP6Config *setting,
}
copy = nm_ip6_route_dup (route);
g_return_val_if_fail (copy != NULL, FALSE);
priv->routes = g_slist_append (priv->routes, copy);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ROUTES);
return TRUE;
......
......@@ -1140,8 +1140,6 @@ fail:
nm_log_err (LOGD_CORE, "Failed asserting path component: NULL");
else
nm_log_err (LOGD_CORE, "Failed asserting path component: \"%s\"", name);
g_assert_not_reached ();
g_return_val_if_reached ("XXXXX");
return "XXXXX";
g_error ("FATAL: Failed asserting path component: %s", name ? name : "(null)");
}
......@@ -119,7 +119,6 @@ constructor (GType type,
GObject *object;
GObjectClass *klass;
NMDeviceOlpcMesh *self;
NMDeviceOlpcMeshPrivate *priv;
NMDeviceWifiCapabilities caps;
klass = G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class);
......@@ -128,7 +127,6 @@ constructor (GType type,
return NULL;
self = NM_DEVICE_OLPC_MESH (object);
priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
nm_log_dbg (LOGD_HW | LOGD_OLPC_MESH, "(%s): kernel ifindex %d",
nm_device_get_iface (NM_DEVICE (self)),
......
......@@ -259,12 +259,13 @@ get_credentials (char *username, char *password)
size_t len;
GError *err = NULL;
if (username && !password) {
if (!password) {
/* pppd is checking pap support; return 1 for supported */
g_return_val_if_fail (username, -1);
return 1;
}
g_return_val_if_fail (username && password, -1);
g_return_val_if_fail (username, -1);
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), -1);
g_message ("nm-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__);
......
......@@ -50,11 +50,8 @@ expected_key_new (const char *key, const char *data)
ExpectedKey *k;
k = g_malloc0 (sizeof (ExpectedKey));
g_assert (k);
k->key = g_strdup (key);
g_assert (k->key);
k->data = g_strdup (data);
g_assert (k->data);
return k;
}
......@@ -108,11 +105,7 @@ expected_block_add_key (ExpectedBlock *b, ExpectedKey *k)
static Expected *
expected_new (void)
{
Expected *e;
e = g_malloc0 (sizeof (Expected));
g_assert (e);
return e;
return g_malloc0 (sizeof (Expected));
}
static void
......
......@@ -349,7 +349,10 @@ nm_editor_utils_create_connection (GType type,
slave_setting_type = types[i]->slave_setting_type;
}
g_return_val_if_fail (type_data != NULL, NULL);
if (!type_data) {
g_return_val_if_reached (NULL);
return NULL;
}
connection = nm_connection_new ();
......
......@@ -255,6 +255,7 @@ main (int argc, char **argv)
nm_settings = nm_remote_settings_new (NULL);
g_signal_connect (nm_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ,
G_CALLBACK (connections_read), &got_connections);
/* coverity[loop_condition] */
while (!got_connections)
g_main_context_iteration (NULL, TRUE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment