[gnome-disk-utility] Add more compiler warnings
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Add more compiler warnings
- Date: Fri, 6 Jul 2012 17:09:59 +0000 (UTC)
commit fe281b024751315741a7ea0c4387f7271ac1e41b
Author: David Zeuthen <zeuthen gmail com>
Date: Fri Jul 6 13:07:48 2012 -0400
Add more compiler warnings
You'd think GNOME_COMPILE_WARNINGS([maximum]) would be good enough but
apparently not. I hate build systems.
Signed-off-by: David Zeuthen <zeuthen gmail com>
acinclude.m4 | 319 +++++++++++++++++++++++++++++++++
configure.ac | 17 ++
src/disk-image-mounter/main.c | 21 +--
src/disks/gdubenchmarkdialog.c | 26 ++--
src/disks/gducreatediskimagedialog.c | 2 +-
src/disks/gducrypttabdialog.c | 10 +-
src/disks/gdudevicetreemodel.c | 4 +-
src/disks/gdudisksettingsdialog.c | 2 -
src/disks/gduestimator.c | 2 +-
src/disks/gdufstabdialog.c | 22 ++--
src/disks/gdurestorediskimagedialog.c | 2 +-
src/disks/gduvolumegrid.c | 11 +-
src/disks/gduwindow.c | 5 -
13 files changed, 383 insertions(+), 60 deletions(-)
---
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 0000000..d151596
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,319 @@
+dnl Macros to check the presence of generic (non-typed) symbols.
+dnl Copyright (c) 2006-2008 Diego Pettenà <flameeyes gmail com>
+dnl Copyright (c) 2006-2008 xine project
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3, or (at your option)
+dnl any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+dnl
+dnl As a special exception, the copyright owners of the
+dnl macro gives unlimited permission to copy, distribute and modify the
+dnl configure scripts that are the output of Autoconf when processing the
+dnl Macro. You need not follow the terms of the GNU General Public
+dnl License when using or distributing such scripts, even though portions
+dnl of the text of the Macro appear in them. The GNU General Public
+dnl License (GPL) does govern all other use of the material that
+dnl constitutes the Autoconf Macro.
+dnl
+dnl This special exception to the GPL applies to versions of the
+dnl Autoconf Macro released by this project. When you make and
+dnl distribute a modified version of the Autoconf Macro, you may extend
+dnl this special exception to the GPL to apply to your modified version as
+dnl well.
+
+dnl Check if the flag is supported by compiler
+dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
+ AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],
+ [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl Check if the flag is supported by compiler (cacheable)
+dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_CFLAGS], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_cflags_$1]),
+ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+ )
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
+dnl Check for CFLAG and appends them to CFLAGS if supported
+AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_cflags_$1]),
+ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+ )
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+ [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3])
+])
+
+dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
+AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
+ for flag in $1; do
+ CC_CHECK_CFLAG_APPEND($flag, [$2], [$3])
+ done
+])
+
+dnl Check if the flag is supported by linker (cacheable)
+dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_LDFLAGS], [
+ AC_CACHE_CHECK([if $CC supports $1 flag],
+ AS_TR_SH([cc_cv_ldflags_$1]),
+ [ac_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $1"
+ AC_LANG_PUSH([C])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])],
+ [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
+ AC_LANG_POP([C])
+ LDFLAGS="$ac_save_LDFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
+ [$2], [$3])
+])
+
+dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
+dnl the current linker to avoid undefined references in a shared object.
+AC_DEFUN([CC_NOUNDEFINED], [
+ dnl We check $host for which systems to enable this for.
+ AC_REQUIRE([AC_CANONICAL_HOST])
+
+ case $host in
+ dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
+ dnl are requested, as different implementations are present; to avoid problems
+ dnl use -Wl,-z,defs only for those platform not behaving this way.
+ *-freebsd* | *-openbsd*) ;;
+ *)
+ dnl First of all check for the --no-undefined variant of GNU ld. This allows
+ dnl for a much more readable commandline, so that people can understand what
+ dnl it does without going to look for what the heck -z defs does.
+ for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
+ CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
+ break
+ done
+ ;;
+ esac
+
+ AC_SUBST([LDFLAGS_NOUNDEFINED])
+])
+
+dnl Check for a -Werror flag or equivalent. -Werror is the GCC
+dnl and ICC flag that tells the compiler to treat all the warnings
+dnl as fatal. We usually need this option to make sure that some
+dnl constructs (like attributes) are not simply ignored.
+dnl
+dnl Other compilers don't support -Werror per se, but they support
+dnl an equivalent flag:
+dnl - Sun Studio compiler supports -errwarn=%all
+AC_DEFUN([CC_CHECK_WERROR], [
+ AC_CACHE_CHECK(
+ [for $CC way to treat warnings as errors],
+ [cc_cv_werror],
+ [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
+ [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
+ ])
+])
+
+AC_DEFUN([CC_CHECK_ATTRIBUTE], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
+ AS_TR_SH([cc_cv_attribute_$1]),
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ AC_LANG_PUSH([C])
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
+ [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
+ [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
+ AC_LANG_POP([C])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
+ [AC_DEFINE(
+ AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
+ [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
+ )
+ $4],
+ [$5])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
+ CC_CHECK_ATTRIBUTE(
+ [constructor],,
+ [void __attribute__((constructor)) ctor() { int a; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
+ CC_CHECK_ATTRIBUTE(
+ [format], [format(printf, n, n)],
+ [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
+ CC_CHECK_ATTRIBUTE(
+ [format_arg], [format_arg(printf)],
+ [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
+ CC_CHECK_ATTRIBUTE(
+ [visibility_$1], [visibility("$1")],
+ [void __attribute__((visibility("$1"))) $1_function() { }],
+ [$2], [$3])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
+ CC_CHECK_ATTRIBUTE(
+ [nonnull], [nonnull()],
+ [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
+ CC_CHECK_ATTRIBUTE(
+ [unused], ,
+ [void some_function(void *foo, __attribute__((unused)) void *bar);],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
+ CC_CHECK_ATTRIBUTE(
+ [sentinel], ,
+ [void some_function(void *foo, ...) __attribute__((sentinel));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
+ CC_CHECK_ATTRIBUTE(
+ [deprecated], ,
+ [void some_function(void *foo, ...) __attribute__((deprecated));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
+ CC_CHECK_ATTRIBUTE(
+ [alias], [weak, alias],
+ [void other_function(void *foo) { }
+ void some_function(void *foo) __attribute__((weak, alias("other_function")));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
+ CC_CHECK_ATTRIBUTE(
+ [malloc], ,
+ [void * __attribute__((malloc)) my_alloc(int n);],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_PACKED], [
+ CC_CHECK_ATTRIBUTE(
+ [packed], ,
+ [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONST], [
+ CC_CHECK_ATTRIBUTE(
+ [const], ,
+ [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
+ [$1], [$2])
+])
+
+AC_DEFUN([CC_FLAG_VISIBILITY], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
+ [cc_cv_flag_visibility],
+ [cc_flag_visibility_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
+ cc_cv_flag_visibility='yes',
+ cc_cv_flag_visibility='no')
+ CFLAGS="$cc_flag_visibility_save_CFLAGS"])
+
+ AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
+ [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
+ [Define this if the compiler supports the -fvisibility flag])
+ $1],
+ [$2])
+])
+
+AC_DEFUN([CC_FUNC_EXPECT], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([if compiler has __builtin_expect function],
+ [cc_cv_func_expect],
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ AC_LANG_PUSH([C])
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+ [int some_function() {
+ int a = 3;
+ return (int)__builtin_expect(a, 3);
+ }])],
+ [cc_cv_func_expect=yes],
+ [cc_cv_func_expect=no])
+ AC_LANG_POP([C])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ AS_IF([test "x$cc_cv_func_expect" = "xyes"],
+ [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
+ [Define this if the compiler supports __builtin_expect() function])
+ $1],
+ [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
+ [cc_cv_attribute_aligned],
+ [ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $cc_cv_werror"
+ AC_LANG_PUSH([C])
+ for cc_attribute_align_try in 64 32 16 8 4 2; do
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+ int main() {
+ static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
+ return c;
+ }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
+ done
+ AC_LANG_POP([C])
+ CFLAGS="$ac_save_CFLAGS"
+ ])
+
+ if test "x$cc_cv_attribute_aligned" != "x"; then
+ AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
+ [Define the highest alignment supported])
+ fi
+])
diff --git a/configure.ac b/configure.ac
index 2dfc45a..87e5452 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,23 @@ GNOME_DEBUG_CHECK
GNOME_COMPILE_WARNINGS([maximum])
GNOME_MAINTAINER_MODE_DEFINES
+# ***********
+# Compilation
+# ***********
+
+CC_CHECK_CFLAGS_APPEND([ \
+ -Wall -Wextra \
+ -Wformat-nonliteral -Werror=format-security \
+ -Wsign-compare -Werror=implicit-function-declaration \
+ -Wpointer-arith -Wwrite-strings -Wstrict-prototypes \
+ -Waggregate-return -Wcast-align -Wimplicit -Wuninitialized \
+ -Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
+ -Wpacked -Wmissing-format-attribute -Wshadow \
+ -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
+ -Wdeclaration-after-statement -Wold-style-definition \
+ -Wno-missing-field-initializers -Wno-unused-parameter \
+ -fno-common -Wno-switch-enum])
+
# ***************************
# Check for required packages
# ***************************
diff --git a/src/disk-image-mounter/main.c b/src/disk-image-mounter/main.c
index 4f5651c..56e4e14 100644
--- a/src/disk-image-mounter/main.c
+++ b/src/disk-image-mounter/main.c
@@ -94,7 +94,7 @@ show_error (const gchar *format, ...)
GTK_BUTTONS_CLOSE,
"<big><b>%s</b></big>",
_("An error occurred"));
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), s);
+ gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", s);
gtk_window_set_title (GTK_WINDOW (dialog), _("Disk Image Mounter"));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
@@ -193,7 +193,7 @@ main (int argc, char *argv[])
GError *error = NULL;
gchar *s = NULL;
GOptionContext *o = NULL;
- guint n;
+ gint n;
GSList *uris = NULL;
GSList *l;
GList *loop_device_objpaths = NULL;
@@ -256,7 +256,6 @@ main (int argc, char *argv[])
GUnixFDList *fd_list = NULL;
GVariantBuilder options_builder;
gint fd;
- GError *error;
gchar *loop_object_path = NULL;
UDisksObject *object;
UDisksFilesystem *filesystem;
@@ -302,7 +301,7 @@ main (int argc, char *argv[])
{
show_error (_("Error attaching disk image: %s (%s, %d)"),
error->message, g_quark_to_string (error->domain), error->code);
- g_error_free (error);
+ g_clear_error (&error);
goto done_with_image;
}
@@ -317,11 +316,11 @@ main (int argc, char *argv[])
partition_table = udisks_object_peek_partition_table (object);
if (partition_table != NULL)
{
- GList *partitions, *l;
+ GList *partitions, *ll;
partitions = udisks_client_get_partitions (udisks_client, partition_table);
- for (l = partitions; l != NULL; l = l->next)
+ for (ll = partitions; ll != NULL; ll = ll->next)
{
- UDisksPartition *partition = UDISKS_PARTITION (l->data);
+ UDisksPartition *partition = UDISKS_PARTITION (ll->data);
UDisksObject *partition_object;
UDisksBlock *partition_block;
UDisksFilesystem *partition_filesystem;
@@ -350,7 +349,7 @@ main (int argc, char *argv[])
show_error (_("Error mounting filesystem on partition %d of disk image: %s (%s, %d)"),
udisks_partition_get_number (partition),
error->message, g_quark_to_string (error->domain), error->code);
- g_error_free (error);
+ g_clear_error (&error);
goto done_with_image;
}
num_mounts++;
@@ -375,7 +374,7 @@ main (int argc, char *argv[])
{
show_error (_("Error mounting filesystem: %s (%s, %d)"),
error->message, g_quark_to_string (error->domain), error->code);
- g_error_free (error);
+ g_clear_error (&error);
goto done_with_image;
}
num_mounts++;
@@ -402,7 +401,7 @@ main (int argc, char *argv[])
*/
g_printerr (_("Non-fatal error: error setting autoclear to TRUE: %s (%s, %d)\n"),
error->message, g_quark_to_string (error->domain), error->code);
- g_error_free (error);
+ g_clear_error (&error);
}
loop_device_objpaths = g_list_prepend (loop_device_objpaths, g_strdup (loop_object_path));
}
@@ -417,7 +416,7 @@ main (int argc, char *argv[])
{
show_error (_("Error cleaning up loop device: %s (%s, %d)"),
error->message, g_quark_to_string (error->domain), error->code);
- g_error_free (error);
+ g_clear_error (&error);
}
}
diff --git a/src/disks/gdubenchmarkdialog.c b/src/disks/gdubenchmarkdialog.c
index 7e671db..457cddb 100644
--- a/src/disks/gdubenchmarkdialog.c
+++ b/src/disks/gdubenchmarkdialog.c
@@ -509,10 +509,10 @@ on_drawing_area_draw (GtkWidget *widget,
cairo_set_line_width (cr, 1.5);
for (n = 0; n < data->bm_read_samples->len; n++)
{
- BMSample *s = &g_array_index (data->bm_read_samples, BMSample, n);
+ BMSample *sample = &g_array_index (data->bm_read_samples, BMSample, n);
- x = gx + gw * s->offset / data->bm_size;
- y = gy + gh - gh * s->value / max_visible_speed;
+ x = gx + gw * sample->offset / data->bm_size;
+ y = gy + gh - gh * sample->value / max_visible_speed;
if (n == 0)
cairo_move_to (cr, x, y);
@@ -526,9 +526,9 @@ on_drawing_area_draw (GtkWidget *widget,
cairo_set_line_width (cr, 1.5);
for (n = 0; n < data->bm_write_samples->len; n++)
{
- BMSample *s = &g_array_index (data->bm_write_samples, BMSample, n);
- x = gx + gw * s->offset / data->bm_size;
- y = gy + gh - gh * s->value / max_visible_speed;
+ BMSample *sample = &g_array_index (data->bm_write_samples, BMSample, n);
+ x = gx + gw * sample->offset / data->bm_size;
+ y = gy + gh - gh * sample->value / max_visible_speed;
if (n == 0)
cairo_move_to (cr, x, y);
@@ -541,10 +541,10 @@ on_drawing_area_draw (GtkWidget *widget,
cairo_set_line_width (cr, 0.5);
for (n = 0; n < data->bm_access_time_samples->len; n++)
{
- BMSample *s = &g_array_index (data->bm_access_time_samples, BMSample, n);
+ BMSample *sample = &g_array_index (data->bm_access_time_samples, BMSample, n);
- x = gx + gw * s->offset / data->bm_size;
- y = gy + gh - gh * s->value / max_visible_time;
+ x = gx + gw * sample->offset / data->bm_size;
+ y = gy + gh - gh * sample->value / max_visible_time;
/*g_debug ("time = %f @ %f", point->value, x);*/
@@ -1144,7 +1144,7 @@ maybe_load_data (DialogData *data,
static GVariant *
samples_to_gvariant (GArray *array)
{
- gint n;
+ guint n;
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(td)"));
@@ -1244,7 +1244,7 @@ benchmark_thread (gpointer user_data)
guchar *buffer = NULL;
GRand *rand = NULL;
int fd = -1;
- guint n;
+ gint n;
long page_size;
guint64 disk_size;
GVariantBuilder options_builder;
@@ -1302,7 +1302,7 @@ benchmark_thread (gpointer user_data)
{
gint64 begin_usec;
gint64 end_usec;
- guint64 offset;
+ gint64 offset;
ssize_t num_read;
BMSample sample = {0};
@@ -1448,7 +1448,7 @@ benchmark_thread (gpointer user_data)
{
gint64 begin_usec;
gint64 end_usec;
- guint64 offset;
+ gint64 offset;
ssize_t num_read;
BMSample sample = {0};
diff --git a/src/disks/gducreatediskimagedialog.c b/src/disks/gducreatediskimagedialog.c
index 3ff129d..14c2221 100644
--- a/src/disks/gducreatediskimagedialog.c
+++ b/src/disks/gducreatediskimagedialog.c
@@ -393,7 +393,7 @@ open_cb (UDisksBlock *block,
*/
if (ioctl (fd, BLKGETSIZE64, &data->block_size) != 0)
{
- error = g_error_new (G_IO_ERROR, g_io_error_from_errno (errno), strerror (errno));
+ error = g_error_new (G_IO_ERROR, g_io_error_from_errno (errno), "%s", strerror (errno));
gdu_window_show_error (data->window, _("Error determining size of device"), error);
g_error_free (error);
create_disk_image_data_complete (data);
diff --git a/src/disks/gducrypttabdialog.c b/src/disks/gducrypttabdialog.c
index df83a93..a948a2f 100644
--- a/src/disks/gducrypttabdialog.c
+++ b/src/disks/gducrypttabdialog.c
@@ -251,7 +251,6 @@ crypttab_dialog_present (CrypttabDialogData *data)
if (response == GTK_RESPONSE_OK)
{
- gboolean configured;
gboolean ui_configured;
GError *error;
@@ -287,7 +286,6 @@ crypttab_dialog_present (CrypttabDialogData *data)
const gchar *ui_options;
const gchar *ui_passphrase_contents;
const gchar *old_passphrase_path;
- GError *error;
GVariant *old_item = NULL;
GVariant *new_item = NULL;
GVariantBuilder builder;
@@ -300,11 +298,11 @@ crypttab_dialog_present (CrypttabDialogData *data)
old_passphrase_path = NULL;
if (data->orig_crypttab_entry != NULL)
{
- const gchar *s;
- if (g_variant_lookup (data->orig_crypttab_entry, "passphrase-path", "^&ay", &s))
+ const gchar *path;
+ if (g_variant_lookup (data->orig_crypttab_entry, "passphrase-path", "^&ay", &path))
{
- if (strlen (s) > 0 && !g_str_has_prefix (s, "/dev"))
- old_passphrase_path = s;
+ if (strlen (path) > 0 && !g_str_has_prefix (path, "/dev"))
+ old_passphrase_path = path;
}
error = NULL;
old_item = g_variant_new ("(s a{sv})", "crypttab",
diff --git a/src/disks/gdudevicetreemodel.c b/src/disks/gdudevicetreemodel.c
index 7de3547..824c328 100644
--- a/src/disks/gdudevicetreemodel.c
+++ b/src/disks/gdudevicetreemodel.c
@@ -389,6 +389,8 @@ gdu_device_tree_model_constructed (GObject *object)
GduDeviceTreeModel *model = GDU_DEVICE_TREE_MODEL (object);
GType types[GDU_DEVICE_TREE_MODEL_N_COLUMNS];
+ G_STATIC_ASSERT (10 == GDU_DEVICE_TREE_MODEL_N_COLUMNS);
+
types[0] = G_TYPE_STRING;
types[1] = G_TYPE_BOOLEAN;
types[2] = G_TYPE_STRING;
@@ -399,7 +401,6 @@ gdu_device_tree_model_constructed (GObject *object)
types[7] = G_TYPE_UINT;
types[8] = G_TYPE_BOOLEAN;
types[9] = G_TYPE_BOOLEAN;
- G_STATIC_ASSERT (10 == GDU_DEVICE_TREE_MODEL_N_COLUMNS);
gtk_tree_store_set_column_types (GTK_TREE_STORE (model),
GDU_DEVICE_TREE_MODEL_N_COLUMNS,
types);
@@ -749,7 +750,6 @@ update_drive (GduDeviceTreeModel *model,
if (ata != NULL)
{
- gchar *s;
s = gdu_ata_smart_get_one_liner_assessment (ata, NULL /* out_smart_supported */, &warning);
g_free (s);
}
diff --git a/src/disks/gdudisksettingsdialog.c b/src/disks/gdudisksettingsdialog.c
index 2ef9f7f..8ce7445 100644
--- a/src/disks/gdudisksettingsdialog.c
+++ b/src/disks/gdudisksettingsdialog.c
@@ -77,8 +77,6 @@ typedef struct
} DialogData;
-G_LOCK_DEFINE (bm_lock);
-
static const struct {
goffset offset;
const gchar *name;
diff --git a/src/disks/gduestimator.c b/src/disks/gduestimator.c
index f1e7c01..9fc0e2a 100644
--- a/src/disks/gduestimator.c
+++ b/src/disks/gduestimator.c
@@ -136,7 +136,6 @@ update (GduEstimator *estimator)
guint n;
gdouble sum_of_speeds;
guint num_speeds;
- gdouble speed;
num_speeds = 0;
sum_of_speeds = 0.0;
@@ -153,6 +152,7 @@ update (GduEstimator *estimator)
estimator->usec_remaining = 0;
if (num_speeds > 0)
{
+ gdouble speed;
speed = sum_of_speeds / num_speeds;
estimator->bytes_per_sec = speed;
if (estimator->bytes_per_sec > 0)
diff --git a/src/disks/gdufstabdialog.c b/src/disks/gdufstabdialog.c
index a24201d..3faa90c 100644
--- a/src/disks/gdufstabdialog.c
+++ b/src/disks/gdufstabdialog.c
@@ -541,16 +541,16 @@ gdu_fstab_dialog_show (GduWindow *window,
const gchar *ui_dir;
const gchar *ui_type;
const gchar *ui_opts;
- gint freq = 0;
- gint passno = 0;
GVariant *old_item = NULL;
GVariant *new_item = NULL;
- GVariantBuilder builder;
+ GVariantBuilder variant_builder;
ui_fsname = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (data.device_combobox));
ui_dir = gtk_entry_get_text (GTK_ENTRY (data.directory_entry));
ui_type = gtk_entry_get_text (GTK_ENTRY (data.type_entry));
ui_opts = gtk_entry_get_text (GTK_ENTRY (data.options_entry));
+ freq = 0;
+ passno = 0;
if (data.orig_fstab_entry != NULL)
{
g_variant_lookup (data.orig_fstab_entry, "freq", "i", &freq);
@@ -560,14 +560,14 @@ gdu_fstab_dialog_show (GduWindow *window,
if (data.orig_fstab_entry != NULL)
old_item = g_variant_new ("(s a{sv})", "fstab", data.orig_fstab_entry);
- g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
- g_variant_builder_add (&builder, "{sv}", "fsname", g_variant_new_bytestring (ui_fsname));
- g_variant_builder_add (&builder, "{sv}", "dir", g_variant_new_bytestring (ui_dir));
- g_variant_builder_add (&builder, "{sv}", "type", g_variant_new_bytestring (ui_type));
- g_variant_builder_add (&builder, "{sv}", "opts", g_variant_new_bytestring (ui_opts));
- g_variant_builder_add (&builder, "{sv}", "freq", g_variant_new_int32 (freq));
- g_variant_builder_add (&builder, "{sv}", "passno", g_variant_new_int32 (passno));
- new_item = g_variant_new ("(sa{sv})", "fstab", &builder);
+ g_variant_builder_init (&variant_builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add (&variant_builder, "{sv}", "fsname", g_variant_new_bytestring (ui_fsname));
+ g_variant_builder_add (&variant_builder, "{sv}", "dir", g_variant_new_bytestring (ui_dir));
+ g_variant_builder_add (&variant_builder, "{sv}", "type", g_variant_new_bytestring (ui_type));
+ g_variant_builder_add (&variant_builder, "{sv}", "opts", g_variant_new_bytestring (ui_opts));
+ g_variant_builder_add (&variant_builder, "{sv}", "freq", g_variant_new_int32 (freq));
+ g_variant_builder_add (&variant_builder, "{sv}", "passno", g_variant_new_int32 (passno));
+ new_item = g_variant_new ("(sa{sv})", "fstab", &variant_builder);
if (old_item == NULL && new_item != NULL)
{
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index 5648cbe..03609e1 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -554,7 +554,7 @@ open_cb (UDisksBlock *block,
*/
if (ioctl (fd, BLKGETSIZE64, &data->block_size) != 0)
{
- error = g_error_new (G_IO_ERROR, g_io_error_from_errno (errno), strerror (errno));
+ error = g_error_new (G_IO_ERROR, g_io_error_from_errno (errno), "%s", strerror (errno));
gdu_window_show_error (data->window, _("Error determining size of device"), error);
g_error_free (error);
restore_disk_image_data_complete (data);
diff --git a/src/disks/gduvolumegrid.c b/src/disks/gduvolumegrid.c
index bbadcb3..fda9f70 100644
--- a/src/disks/gduvolumegrid.c
+++ b/src/disks/gduvolumegrid.c
@@ -642,8 +642,6 @@ recompute_size_for_slice (GList *elements,
extra -= get_num_elements_for_slice (element->embedded_elements) * ELEMENT_MINIMUM_WIDTH;
}
- g_warn_if_fail (width >= 0);
-
x = 0;
for (l = elements; l != NULL; l = l->next)
{
@@ -798,13 +796,13 @@ render_element (GduVolumeGrid *grid,
/* icons */
icons_to_render = g_ptr_array_new_with_free_func (NULL);
if (element->show_padlock_open)
- g_ptr_array_add (icons_to_render, "changes-allow-symbolic");
+ g_ptr_array_add (icons_to_render, (gpointer) "changes-allow-symbolic");
if (element->show_padlock_closed)
- g_ptr_array_add (icons_to_render, "changes-prevent-symbolic");
+ g_ptr_array_add (icons_to_render, (gpointer) "changes-prevent-symbolic");
if (element->show_mounted)
- g_ptr_array_add (icons_to_render, "media-playback-start-symbolic");
+ g_ptr_array_add (icons_to_render, (gpointer) "media-playback-start-symbolic");
if (element->show_configured)
- g_ptr_array_add (icons_to_render, "user-bookmarks-symbolic");
+ g_ptr_array_add (icons_to_render, (gpointer) "user-bookmarks-symbolic");
if (icons_to_render->len > 0)
{
guint icon_offset = 0;
@@ -1656,7 +1654,6 @@ grid_element_set_details (GduVolumeGrid *grid,
}
else if (g_strcmp0 (usage, "other") == 0 && g_strcmp0 (type, "swap") == 0)
{
- const gchar *label;
UDisksSwapspace *swapspace;
label = udisks_block_get_id_label (block);
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 328a447..95795da 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -1986,7 +1986,6 @@ update_device_page_for_drive (GduWindow *window,
else
{
UDisksJob *job = UDISKS_JOB (jobs->data);
- gchar *s;
gtk_widget_show (window->devtab_drive_job_label);
gtk_widget_show (window->devtab_drive_job_grid);
@@ -2179,7 +2178,6 @@ update_device_page_for_block (GduWindow *window,
if (partition != NULL)
{
- gchar *s;
s = udisks_client_get_partition_info (window->client, partition);
if (s == NULL)
s = g_strdup (C_("partition type", "Unknown"));
@@ -2192,7 +2190,6 @@ update_device_page_for_block (GduWindow *window,
if (loop != NULL)
{
- gchar *s;
s = gdu_utils_unfuse_path (udisks_loop_get_backing_file (loop));
set_markup (window,
"devtab-backing-file-label",
@@ -2354,7 +2351,6 @@ update_device_page_for_block (GduWindow *window,
else
{
UDisksJob *job = UDISKS_JOB (jobs->data);
- gchar *s;
gtk_widget_show (window->devtab_job_label);
gtk_widget_show (window->devtab_job_grid);
@@ -2433,7 +2429,6 @@ update_device_page_for_free_space (GduWindow *window,
if (loop != NULL)
{
- gchar *s;
s = gdu_utils_unfuse_path (udisks_loop_get_backing_file (loop));
set_markup (window,
"devtab-backing-file-label",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]