[gnome-power-manager] Use a larger set of warning flags
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-power-manager] Use a larger set of warning flags
- Date: Mon, 29 Aug 2016 08:38:18 +0000 (UTC)
commit e996895f6d193d0fdb495cbc69a57c4bd45e6db4
Author: Richard Hughes <richard hughsie com>
Date: Mon Aug 29 09:37:03 2016 +0100
Use a larger set of warning flags
configure.ac | 73 ++++++++++++++++++++++++++++++-----------------
src/Makefile.am | 5 ++-
src/gpm-array-float.c | 6 ++--
src/gpm-graph-widget.h | 1 -
src/gpm-statistics.c | 20 ++++---------
5 files changed, 59 insertions(+), 46 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8707a90..d17d6a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,33 +21,52 @@ GNOME_COMPILE_WARNINGS
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
-if test "$GCC" = "yes"; then
- WARNINGFLAGS="$WARNINGFLAGS -Wall"
- WARNINGFLAGS="$WARNINGFLAGS -Wcast-align -Wno-uninitialized"
- WARNINGFLAGS="$WARNINGFLAGS -Wmissing-declarations"
- WARNINGFLAGS="$WARNINGFLAGS -Wpointer-arith"
- WARNINGFLAGS="$WARNINGFLAGS -Wcast-align"
- WARNINGFLAGS="$WARNINGFLAGS -Wwrite-strings"
- WARNINGFLAGS="$WARNINGFLAGS -Winit-self"
- WARNINGFLAGS="$WARNINGFLAGS -Wreturn-type"
- WARNINGFLAGS="$WARNINGFLAGS -Wformat-nonliteral"
- WARNINGFLAGS="$WARNINGFLAGS -Wformat-security"
- WARNINGFLAGS="$WARNINGFLAGS -Wmissing-include-dirs"
- WARNINGFLAGS="$WARNINGFLAGS -Wmissing-format-attribute"
- WARNINGFLAGS="$WARNINGFLAGS -Wclobbered"
- WARNINGFLAGS="$WARNINGFLAGS -Wempty-body"
- WARNINGFLAGS="$WARNINGFLAGS -Wignored-qualifiers"
- WARNINGFLAGS="$WARNINGFLAGS -Wtype-limits"
- WARNINGFLAGS="$WARNINGFLAGS -Wdeclaration-after-statement"
- WARNINGFLAGS="$WARNINGFLAGS -Wshadow"
- WARNINGFLAGS="$WARNINGFLAGS -Winline"
- WARNINGFLAGS="$WARNINGFLAGS -Wmissing-parameter-type"
- WARNINGFLAGS="$WARNINGFLAGS -Woverride-init"
- WARNINGFLAGS="$WARNINGFLAGS -Wno-strict-aliasing"
-else
- WARNINGFLAGS=""
-fi
-AC_SUBST(WARNINGFLAGS)
+WARN_CFLAGS_EXTRA="
+ -Waggregate-return
+ -Warray-bounds
+ -Wcast-align
+ -Wclobbered
+ -Wdeclaration-after-statement
+ -Wempty-body
+ -Wextra
+ -Wformat=2
+ -Wformat-nonliteral
+ -Wformat-security
+ -Wformat-signedness
+ -Wignored-qualifiers
+ -Wimplicit-function-declaration
+ -Winit-self
+ -Winline
+ -Wmissing-declarations
+ -Wmissing-format-attribute
+ -Wmissing-include-dirs
+ -Wmissing-noreturn
+ -Wmissing-parameter-type
+ -Wmissing-prototypes
+ -Wnested-externs
+ -Wno-discarded-qualifiers
+ -Wno-missing-field-initializers
+ -Wno-strict-aliasing
+ -Wno-suggest-attribute=format
+ -Wno-unused-parameter
+ -Wold-style-definition
+ -Woverride-init
+ -Wpacked
+ -Wpointer-arith
+ -Wredundant-decls
+ -Wreturn-type
+ -Wshadow
+ -Wsign-compare
+ -Wstrict-aliasing
+ -Wstrict-prototypes
+ -Wswitch-default
+ -Wtype-limits
+ -Wundef
+ -Wuninitialized
+ -Wunused-but-set-variable
+ -Wwrite-strings"
+AX_APPEND_COMPILE_FLAGS([$WARN_CFLAGS_EXTRA], [WARN_CFLAGS])
+AC_SUBST(WARN_CFLAGS)
dnl ---------------------------------------------------------------------------
dnl - Debugging switches (uncomment this if you want to use gdb)
diff --git a/src/Makefile.am b/src/Makefile.am
index 5471ece..f5b71d8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,7 +47,7 @@ gnome_power_statistics_LDADD = \
-lm
gnome_power_statistics_CFLAGS = \
- $(WARNINGFLAGS)
+ $(WARN_CFLAGS)
gnome_power_self_test_SOURCES = \
gpm-array-float.h \
@@ -65,6 +65,9 @@ gnome_power_self_test_LDADD = \
$(GPM_EXTRA_LIBS) \
-lm
+gnome_power_self_test_CFLAGS = \
+ $(WARN_CFLAGS)
+
gnome_power_self_test_CFLAGS = -DEGG_TEST $(AM_CFLAGS) $(WARNINGFLAGS)
gpm-resources.c: gnome-power-manager.gresource.xml gpm-statistics.ui
diff --git a/src/gpm-array-float.c b/src/gpm-array-float.c
index 960f279..0bb0e7f 100644
--- a/src/gpm-array-float.c
+++ b/src/gpm-array-float.c
@@ -75,7 +75,7 @@ gfloat
gpm_array_float_get (GpmArrayFloat *array, guint i)
{
if (i >= array->len)
- g_error ("above index! (%i)", i);
+ g_error ("above index! (%u)", i);
return g_array_index (array, gfloat, i);
}
@@ -149,7 +149,7 @@ gpm_array_float_compute_gaussian (guint length, gfloat sigma)
half_length = (length / 2) + 1;
for (i = 0; i < half_length; i++) {
division = half_length - (i + 1);
- g_debug ("half_length=%i, div=%f, sigma=%f", half_length, division, sigma);
+ g_debug ("half_length=%u, div=%f, sigma=%f", half_length, division, sigma);
g_array_index (array, gfloat, i) = gpm_array_float_guassian_value (division, sigma);
}
@@ -206,7 +206,7 @@ gpm_array_float_print (GpmArrayFloat *array)
length = array->len;
/* debug out */
for (i = 0; i < length; i++)
- g_debug ("[%i]\tval=%f", i, g_array_index (array, gfloat, i));
+ g_debug ("[%u]\tval=%f", i, g_array_index (array, gfloat, i));
return TRUE;
}
diff --git a/src/gpm-graph-widget.h b/src/gpm-graph-widget.h
index f6cf04d..1aaa93a 100644
--- a/src/gpm-graph-widget.h
+++ b/src/gpm-graph-widget.h
@@ -59,7 +59,6 @@ struct _GpmGraphWidgetClass
GtkDrawingAreaClass parent_class;
};
-GType gpm_graph_widget_get_type (void);
GtkWidget *gpm_graph_widget_new (void);
gboolean gpm_graph_widget_data_clear (GpmGraphWidget *graph);
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index 7fce6b2..efee83e 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -289,7 +289,7 @@ gpm_device_kind_to_localised_string (UpDeviceKind kind, guint number)
break;
#endif
default:
- g_warning ("enum unrecognised: %i", kind);
+ g_warning ("enum unrecognised: %u", kind);
text = up_device_kind_to_string (kind);
}
return text;
@@ -600,9 +600,6 @@ gpm_stats_get_printable_device_path (UpDevice *device)
static void
gpm_stats_update_info_page_details (UpDevice *device)
{
- struct tm *time_tm;
- time_t t;
- gchar time_buf[256];
gchar *text;
guint refreshed;
UpDeviceKind kind;
@@ -655,11 +652,6 @@ gpm_stats_update_info_page_details (UpDevice *device)
"model", &model,
NULL);
- /* get a human readable time */
- t = (time_t) update_time;
- time_tm = localtime (&t);
- strftime (time_buf, sizeof time_buf, "%c", time_tm);
-
/* remove prefix */
device_path = gpm_stats_get_printable_device_path (device);
/* TRANSLATORS: the device ID of the current device, e.g. "battery0" */
@@ -679,7 +671,7 @@ gpm_stats_update_info_page_details (UpDevice *device)
gpm_stats_add_info_data (_("Supply"), gpm_stats_bool_to_string (power_supply));
refreshed = (int) (time (NULL) - update_time);
- text = g_strdup_printf (ngettext ("%d second", "%d seconds", refreshed), refreshed);
+ text = g_strdup_printf (ngettext ("%u second", "%u seconds", refreshed), refreshed);
/* TRANSLATORS: when the device was last updated with new data. It's
* usually a few seconds when a device is discharging or charging. */
@@ -1262,11 +1254,11 @@ gpm_stats_add_wakeups_item (UpWakeupItem *item)
if (up_wakeup_item_get_is_userspace (item)) {
icon = "application-x-executable";
- id = g_strdup_printf ("%i", up_wakeup_item_get_id (item));
+ id = g_strdup_printf ("%u", up_wakeup_item_get_id (item));
} else {
icon = "applications-system";
if (up_wakeup_item_get_id (item) < 0xff0)
- id = g_strdup_printf ("IRQ%i", up_wakeup_item_get_id (item));
+ id = g_strdup_printf ("IRQ%u", up_wakeup_item_get_id (item));
else
id = g_strdup ("IRQx");
}
@@ -1320,7 +1312,7 @@ gpm_stats_update_wakeups_data (void)
widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_total_wakeups"));
if (error == NULL) {
g_autofree gchar *text = NULL;
- text = g_strdup_printf ("%i", total);
+ text = g_strdup_printf ("%u", total);
} else {
gtk_label_set_label (GTK_LABEL(widget), error->message);
g_error_free (error);
@@ -1748,7 +1740,7 @@ gpm_stats_highlight_device (const gchar *object_path)
-1);
if (g_strcmp0 (id, object_path) == 0) {
g_autofree gchar *path_str = NULL;
- path_str = g_strdup_printf ("%i", i);
+ path_str = g_strdup_printf ("%u", i);
path = gtk_tree_path_new_from_string (path_str);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_devices"));
gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (widget), path, NULL, NULL, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]