summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-12-05 09:39:12 +0100
committerJiří Klimeš <jklimes@redhat.com>2014-12-05 09:39:12 +0100
commit9e2203c418816578c2b5c2f73a739024c7fef202 (patch)
tree8cce1a933fe6387fb301dc55671ecbee1f30e711
parent87f2b92da3b6775dfb21fa2973c28c31a31edcdd (diff)
parent49bbafbb160740c0a5634738745748178d7e8308 (diff)
downloadNetworkManager-9e2203c418816578c2b5c2f73a739024c7fef202.tar.gz
merge: fix number of defects found by Coverity scan (bgo #741122)
https://bugzilla.gnome.org/show_bug.cgi?id=741122
-rw-r--r--callouts/nm-dispatcher.c2
-rw-r--r--clients/tui/newt/nmt-newt-section.c8
-rw-r--r--clients/tui/nmtui-edit.c2
-rw-r--r--libnm-core/nm-setting-8021x.c3
-rw-r--r--libnm/nm-dhcp-config.c1
-rw-r--r--libnm/nm-object.c2
-rw-r--r--src/NetworkManagerUtils.c27
-rw-r--r--src/devices/bluetooth/nm-device-bt.c5
-rw-r--r--src/platform/nm-platform.c8
9 files changed, 36 insertions, 22 deletions
diff --git a/callouts/nm-dispatcher.c b/callouts/nm-dispatcher.c
index dafe4f6e63..0cd2531dda 100644
--- a/callouts/nm-dispatcher.c
+++ b/callouts/nm-dispatcher.c
@@ -296,7 +296,7 @@ script_timeout_cb (gpointer user_data)
if (kill (script->pid, 0) == 0)
kill (script->pid, SIGKILL);
- waitpid (script->pid, NULL, 0);
+ (void) waitpid (script->pid, NULL, 0);
script->error = g_strdup_printf ("Script '%s' timed out.", script->script);
script->result = DISPATCH_RESULT_TIMEOUT;
diff --git a/clients/tui/newt/nmt-newt-section.c b/clients/tui/newt/nmt-newt-section.c
index df5b188945..1a5035fc09 100644
--- a/clients/tui/newt/nmt-newt-section.c
+++ b/clients/tui/newt/nmt-newt-section.c
@@ -260,12 +260,12 @@ nmt_newt_section_size_request (NmtNewtWidget *widget,
int *height)
{
NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE (widget);
- int border_width, border_height;
+ int w_ignore, h_ignore;
g_return_if_fail (priv->header != NULL && priv->body != NULL);
if (priv->show_border)
- nmt_newt_widget_size_request (priv->border_grid, &border_width, &border_height);
+ nmt_newt_widget_size_request (priv->border_grid, &w_ignore, &h_ignore);
nmt_newt_widget_size_request (priv->header, &priv->hwidth_req, &priv->hheight_req);
nmt_newt_widget_size_request (priv->body, &priv->bwidth_req, &priv->bheight_req);
@@ -322,10 +322,10 @@ nmt_newt_section_size_allocate (NmtNewtWidget *widget,
NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE (widget);
if (priv->show_border) {
- int border_height, border_width;
+ int w_ignore, h_ignore;
adjust_border_for_allocation (priv, height);
- nmt_newt_widget_size_request (priv->border_grid, &border_height, &border_width);
+ nmt_newt_widget_size_request (priv->border_grid, &w_ignore, &h_ignore);
nmt_newt_widget_size_allocate (priv->border_grid, x, y, 1, height);
nmt_newt_widget_size_allocate (priv->header, x + 2, y, width, priv->hheight_req);
} else
diff --git a/clients/tui/nmtui-edit.c b/clients/tui/nmtui-edit.c
index 2cc6b773aa..94d15fb3b2 100644
--- a/clients/tui/nmtui-edit.c
+++ b/clients/tui/nmtui-edit.c
@@ -463,7 +463,7 @@ connection_deleted_callback (GObject *connection,
ConnectionDeleteData *data = user_data;
GError *error = NULL;
- if (!nm_remote_connection_delete_finish (data->connection, result, NULL)) {
+ if (!nm_remote_connection_delete_finish (data->connection, result, &error)) {
nmt_newt_message_dialog (_("Unable to delete connection: %s"),
error->message);
} else
diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c
index 369359f47a..f739f2c720 100644
--- a/libnm-core/nm-setting-8021x.c
+++ b/libnm-core/nm-setting-8021x.c
@@ -1680,8 +1680,9 @@ file_to_secure_bytes (const char *filename)
g_byte_array_append (array, (guint8 *) contents, length);
g_assert (array->len == length);
g_free (contents);
+ return g_bytes_new_with_free_func (array->data, array->len, free_secure_bytes, array);
}
- return g_bytes_new_with_free_func (array->data, array->len, free_secure_bytes, array);
+ return NULL;
}
/**
diff --git a/libnm/nm-dhcp-config.c b/libnm/nm-dhcp-config.c
index 86cbdc3e3c..4a58bf27a6 100644
--- a/libnm/nm-dhcp-config.c
+++ b/libnm/nm-dhcp-config.c
@@ -114,6 +114,7 @@ get_property (GObject *object,
switch (prop_id) {
case PROP_FAMILY:
g_value_set_int (value, nm_dhcp_config_get_family (self));
+ break;
case PROP_OPTIONS:
g_value_set_boxed (value, nm_dhcp_config_get_options (self));
break;
diff --git a/libnm/nm-object.c b/libnm/nm-object.c
index f02c09c2e2..391166b29b 100644
--- a/libnm/nm-object.c
+++ b/libnm/nm-object.c
@@ -919,7 +919,7 @@ handle_property_changed (NMObject *self, const char *dbus_name,
g_free (s);
}
- if (pi->object_type) {
+ if (pspec && pi->object_type) {
if (g_variant_is_of_type (value, G_VARIANT_TYPE_OBJECT_PATH))
success = handle_object_property (self, pspec->name, value, pi, synchronously);
else if (g_variant_is_of_type (value, G_VARIANT_TYPE ("ao")))
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 6ca2d9920d..2ce6e1a396 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -486,6 +486,17 @@ nm_utils_kill_child_async (pid_t pid, int sig, guint64 log_domain,
g_child_watch_add (pid, _kc_cb_watch_child, data);
}
+static inline gulong
+_sleep_duration_convert_ms_to_us (guint32 sleep_duration_msec)
+{
+ if (sleep_duration_msec > 0) {
+ guint64 x = (gint64) sleep_duration_msec * (guint64) 1000L;
+
+ return x < G_MAXULONG ? (gulong) x : G_MAXULONG;
+ }
+ return G_USEC_PER_SEC / 20;
+}
+
/* nm_utils_kill_child_sync:
* @pid: process id to kill
* @sig: signal to sent initially. If 0, no signal is sent. If %SIGKILL, the
@@ -569,7 +580,7 @@ nm_utils_kill_child_sync (pid_t pid, int sig, guint64 log_domain, const char *lo
gulong sleep_time, sleep_duration_usec;
int loop_count = 0;
- sleep_duration_usec = (sleep_duration_msec <= 0) ? (G_USEC_PER_SEC / 20) : MIN (G_MAXULONG, ((gint64) sleep_duration_msec) * 1000L);
+ sleep_duration_usec = _sleep_duration_convert_ms_to_us (sleep_duration_msec);
wait_until = wait_before_kill_msec <= 0 ? 0 : wait_start_us + (((gint64) wait_before_kill_msec) * 1000L);
while (TRUE) {
@@ -723,7 +734,7 @@ nm_utils_kill_process_sync (pid_t pid, guint64 start_time, int sig, guint64 log_
wait_start_us = nm_utils_get_monotonic_timestamp_us ();
- sleep_duration_usec = (sleep_duration_msec == 0) ? (G_USEC_PER_SEC / 20) : MIN (G_MAXULONG, ((gulong) sleep_duration_msec) * 1000UL);
+ sleep_duration_usec = _sleep_duration_convert_ms_to_us (sleep_duration_msec);
wait_until = wait_start_us + (((gint64) wait_before_kill_msec) * 1000L);
while (TRUE) {
@@ -1862,7 +1873,7 @@ monotonic_timestamp_get (struct timespec *tp)
gint64
nm_utils_get_monotonic_timestamp_ns (void)
{
- struct timespec tp;
+ struct timespec tp = { 0 };
monotonic_timestamp_get (&tp);
@@ -1889,7 +1900,7 @@ nm_utils_get_monotonic_timestamp_ns (void)
gint64
nm_utils_get_monotonic_timestamp_us (void)
{
- struct timespec tp;
+ struct timespec tp = { 0 };
monotonic_timestamp_get (&tp);
@@ -1916,7 +1927,7 @@ nm_utils_get_monotonic_timestamp_us (void)
gint64
nm_utils_get_monotonic_timestamp_ms (void)
{
- struct timespec tp;
+ struct timespec tp = { 0 };
monotonic_timestamp_get (&tp);
@@ -1943,7 +1954,7 @@ nm_utils_get_monotonic_timestamp_ms (void)
gint32
nm_utils_get_monotonic_timestamp_s (void)
{
- struct timespec tp;
+ struct timespec tp = { 0 };
monotonic_timestamp_get (&tp);
return (((gint64) tp.tv_sec) + monotonic_timestamp_offset_sec);
@@ -2015,9 +2026,9 @@ _log_connection_sort_names_fcn (gconstpointer a, gconstpointer b)
/* we want to first show the items, that disappeared, then the one that changed and
* then the ones that were added. */
- if ((v1->diff_result & NM_SETTING_DIFF_RESULT_IN_A) != (v1->diff_result & NM_SETTING_DIFF_RESULT_IN_A))
+ if ((v1->diff_result & NM_SETTING_DIFF_RESULT_IN_A) != (v2->diff_result & NM_SETTING_DIFF_RESULT_IN_A))
return (v1->diff_result & NM_SETTING_DIFF_RESULT_IN_A) ? -1 : 1;
- if ((v1->diff_result & NM_SETTING_DIFF_RESULT_IN_B) != (v1->diff_result & NM_SETTING_DIFF_RESULT_IN_B))
+ if ((v1->diff_result & NM_SETTING_DIFF_RESULT_IN_B) != (v2->diff_result & NM_SETTING_DIFF_RESULT_IN_B))
return (v1->diff_result & NM_SETTING_DIFF_RESULT_IN_B) ? 1 : -1;
return strcmp (v1->item_name, v2->item_name);
}
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c
index 2cf2794da6..689f37c9b4 100644
--- a/src/devices/bluetooth/nm-device-bt.c
+++ b/src/devices/bluetooth/nm-device-bt.c
@@ -304,12 +304,11 @@ complete_connection (NMDevice *device,
fallback_prefix = _("GSM connection");
if (!nm_setting_gsm_get_number (s_gsm))
g_object_set (G_OBJECT (s_gsm), NM_SETTING_GSM_NUMBER, "*99#", NULL);
- } else if (s_cdma) {
+ } else {
fallback_prefix = _("CDMA connection");
if (!nm_setting_cdma_get_number (s_cdma))
g_object_set (G_OBJECT (s_cdma), NM_SETTING_GSM_NUMBER, "#777", NULL);
- } else
- fallback_prefix = _("DUN connection");
+ }
} else {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 7433ccd186..04ac4ce089 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -1801,8 +1801,10 @@ nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint3
* The workaround is to configure different device priorities via ipv4.route-metric. */
network = nm_utils_ip4_address_clear_host_address (known_address->address, known_address->plen);
- nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_KERNEL, network, known_address->plen, 0, known_address->address, device_route_metric, 0);
- nm_platform_ip4_route_delete (ifindex, network, known_address->plen, NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE);
+ (void) nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_KERNEL, network, known_address->plen,
+ 0, known_address->address, device_route_metric, 0);
+ (void) nm_platform_ip4_route_delete (ifindex, network, known_address->plen,
+ NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE);
}
return TRUE;
@@ -2070,7 +2072,7 @@ nm_platform_ip4_route_sync (int ifindex, const GArray *known_routes)
route = &g_array_index (routes, NMPlatformIP4Route, i);
if (!array_contains_ip4_route (known_routes, route))
- nm_platform_ip4_route_delete (ifindex, route->network, route->plen, route->metric);
+ (void) nm_platform_ip4_route_delete (ifindex, route->network, route->plen, route->metric);
}
if (!known_routes) {