merge: fix number of defects found by Coverity scan (bgo #741122)

https://bugzilla.gnome.org/show_bug.cgi?id=741122
This commit is contained in:
Jiří Klimeš 2014-12-05 09:39:12 +01:00
commit 9e2203c418
9 changed files with 36 additions and 22 deletions

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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;
}
/**

View file

@ -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;

View file

@ -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")))

View file

@ -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);
}

View file

@ -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,

View file

@ -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) {