From c1fb8a1c11cbebbf805b03d43068ead9ec60327d Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 10 Feb 2010 19:52:46 -0800 Subject: [PATCH] Fix format string errors. Found by Clang (http://clang-analyzer.llvm.org). --- src/language/data-io/combine-files.c | 4 ++-- src/language/dictionary/sys-file-info.c | 13 +++++++------ src/language/expressions/parse.c | 4 ++-- src/language/lexer/q2c.c | 6 +++--- src/language/stats/chisquare.c | 4 ++-- src/ui/gui/main.c | 2 +- src/ui/gui/psppire-syntax-window.c | 8 ++++---- src/ui/terminal/terminal-opts.c | 2 +- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/language/data-io/combine-files.c b/src/language/data-io/combine-files.c index d4b9bf58..15566792 100644 --- a/src/language/data-io/combine-files.c +++ b/src/language/data-io/combine-files.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -562,7 +562,7 @@ merge_dictionary (struct dictionary *const m, struct comb_file *f) ds_put_format (&s, _("In an earlier file, %s was a string " "variable with width %d."), var_name, var_get_width (mv)); - msg (SE, ds_cstr (&s)); + msg (SE, "%s", ds_cstr (&s)); ds_destroy (&s); return false; } diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index 1f47e1af..db871b87 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -120,9 +120,10 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) tab_text (t, 0, 5, TAB_LEFT, _("Variables:")); tab_text_format (t, 1, 5, TAB_LEFT, "%zu", dict_get_var_cnt (d)); tab_text (t, 0, 6, TAB_LEFT, _("Cases:")); - tab_text_format (t, 1, 6, TAB_LEFT, - info.case_cnt == -1 ? _("Unknown") : "%ld", - (long int) info.case_cnt); + if (info.case_cnt == -1) + tab_text (t, 1, 6, TAB_LEFT, _("Unknown")); + else + tab_text_format (t, 1, 6, TAB_LEFT, "%ld", (long int) info.case_cnt); tab_text (t, 0, 7, TAB_LEFT, _("Type:")); tab_text (t, 1, 7, TAB_LEFT, _("System File")); tab_text (t, 0, 8, TAB_LEFT, _("Weight:")); @@ -138,8 +139,8 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) tab_text (t, 0, 10, TAB_LEFT, _("Charset:")); - tab_text_format (t, 1, 10, TAB_LEFT, - dict_get_encoding(d) ? dict_get_encoding(d) : _("Unknown")); + tab_text (t, 1, 10, TAB_LEFT, + dict_get_encoding(d) ? dict_get_encoding(d) : _("Unknown")); tab_submit (t); diff --git a/src/language/expressions/parse.c b/src/language/expressions/parse.c index bdce53c5..3577443d 100644 --- a/src/language/expressions/parse.c +++ b/src/language/expressions/parse.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -577,7 +577,7 @@ parse_binary_operators (struct lexer *lexer, struct expression *e, union any_nod } if (op_count > 1 && chain_warning != NULL) - msg (SW, chain_warning); + msg (SW, "%s", chain_warning); return node; } diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c index be0f29c5..a418866c 100644 --- a/src/language/lexer/q2c.c +++ b/src/language/lexer/q2c.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2008 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2008, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1069,7 +1069,7 @@ dump_declarations (void) if (buf == NULL) buf = xmalloc (1024); else - dump (0, buf); + dump (0, "%s", buf); if (k) sprintf (buf, "%s%s,", st_upper (prefix), sym->name); @@ -1082,7 +1082,7 @@ dump_declarations (void) if (buf) { buf[strlen (buf) - 1] = 0; - dump (0, buf); + dump (0, "%s", buf); free (buf); } if (f) diff --git a/src/language/stats/chisquare.c b/src/language/stats/chisquare.c index 1f2df8d2..4a75acb8 100644 --- a/src/language/stats/chisquare.c +++ b/src/language/stats/chisquare.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -182,7 +182,7 @@ create_variable_frequency_table (const struct dictionary *dict, table = tab_create(4, n_cells + 2); - tab_title (table, var_to_string(var)); + tab_title (table, "%s", var_to_string(var)); tab_text (table, 1, 0, TAB_LEFT, _("Observed N")); tab_text (table, 2, 0, TAB_LEFT, _("Expected N")); tab_text (table, 3, 0, TAB_LEFT, _("Residual")); diff --git a/src/ui/gui/main.c b/src/ui/gui/main.c index 517d74af..e0e680f3 100644 --- a/src/ui/gui/main.c +++ b/src/ui/gui/main.c @@ -168,7 +168,7 @@ main (int argc, char *argv[]) GTK_MINOR_VERSION, GTK_MICRO_VERSION)) ) { - g_warning (vers); + g_warning ("%s", vers); } /* Let GDK remove any options that it owns. */ diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index 48a77fc0..0110fb90 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008, 2009 Free Software Foundation + Copyright (C) 2008, 2009, 2010 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -311,7 +311,7 @@ syntax_save_as (PsppireWindow *se) if ( ! save_editor_to_file (PSPPIRE_SYNTAX_WINDOW (se), filename, &err) ) { - msg ( ME, err->message ); + msg ( ME, "%s", err->message ); g_error_free (err); } @@ -336,7 +336,7 @@ syntax_save (PsppireWindow *se) save_editor_to_file (PSPPIRE_SYNTAX_WINDOW (se), filename, &err); if ( err ) { - msg (ME, err->message); + msg (ME, "%s", err->message); g_error_free (err); } } @@ -570,7 +570,7 @@ error_dialog (GtkWindow *w, const gchar *filename, GError *err) g_object_set (dialog, "icon-name", "psppicon", NULL); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - err->message); + "%s", err->message); gtk_dialog_run (GTK_DIALOG (dialog)); diff --git a/src/ui/terminal/terminal-opts.c b/src/ui/terminal/terminal-opts.c index a0f6072b..7b30ed5f 100644 --- a/src/ui/terminal/terminal-opts.c +++ b/src/ui/terminal/terminal-opts.c @@ -123,7 +123,7 @@ parse_output_option (struct terminal_opts *to, const char *option) key = xmemdup0 (option, equals - option); if (string_map_contains (&to->options, key)) { - error (0, 0, _("%s: output option %s specified more than twice"), key); + error (0, 0, _("%s: output option specified more than once"), key); free (key); return; } -- 2.30.2