From be96174f193f154a18117e3f36172d4a6632ee6b Mon Sep 17 00:00:00 2001 From: benl Date: Wed, 18 May 2011 21:04:29 +0000 Subject: [PATCH] Fix clang warnings. Note: possible minor security issues fixed (untrusted string used as printf format string). Approved by: philip (mentor) --- contrib/groff/src/devices/grohtml/post-html.cpp | 2 +- contrib/groff/src/libs/libdriver/input.cpp | 2 +- contrib/groff/src/roff/troff/mtsm.cpp | 6 ++++-- contrib/groff/src/roff/troff/node.cpp | 2 +- contrib/groff/src/utils/hpftodit/hpftodit.cpp | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/contrib/groff/src/devices/grohtml/post-html.cpp b/contrib/groff/src/devices/grohtml/post-html.cpp index 1283e06139a7..6834e844f801 100644 --- a/contrib/groff/src/devices/grohtml/post-html.cpp +++ b/contrib/groff/src/devices/grohtml/post-html.cpp @@ -1587,7 +1587,7 @@ void header_desc::write_headings (FILE *f, int force) buffer += as_string(h); buffer += '\0'; - fprintf(f, buffer.contents()); + fputs(buffer.contents(), f); } else fputs(g->text_string, f); h++; diff --git a/contrib/groff/src/libs/libdriver/input.cpp b/contrib/groff/src/libs/libdriver/input.cpp index bf8a74e1066c..c2b262af8f03 100644 --- a/contrib/groff/src/libs/libdriver/input.cpp +++ b/contrib/groff/src/libs/libdriver/input.cpp @@ -995,7 +995,7 @@ next_command(void) inline bool odd(const int n) { - return (n & 1 == 1) ? true : false; + return ((n & 1) == 1) ? true : false; } ////////////////////////////////////////////////////////////////////// diff --git a/contrib/groff/src/roff/troff/mtsm.cpp b/contrib/groff/src/roff/troff/mtsm.cpp index 630e973209cd..38efc0a343a5 100644 --- a/contrib/groff/src/roff/troff/mtsm.cpp +++ b/contrib/groff/src/roff/troff/mtsm.cpp @@ -611,14 +611,16 @@ int state_set::is_in(int_value_state i) return (intset & (1 << (int)i)) != 0; } +// Note: this used to have a bug s.t. it always tested for bit 0 (benl 18/5/11) int state_set::is_in(units_value_state u) { - return (unitsset & (1 << (int)u) != 0); + return (unitsset & (1 << (int)u)) != 0; } +// Note: this used to have a bug s.t. it always tested for bit 0 (benl 18/5/11) int state_set::is_in(string_value_state s) { - return (stringset & (1 << (int)s) != 0); + return (stringset & (1 << (int)s)) != 0; } void state_set::add(units_value_state, int n) diff --git a/contrib/groff/src/roff/troff/node.cpp b/contrib/groff/src/roff/troff/node.cpp index 0d874d35758d..0e440b210580 100644 --- a/contrib/groff/src/roff/troff/node.cpp +++ b/contrib/groff/src/roff/troff/node.cpp @@ -2157,7 +2157,7 @@ void glyph_node::debug_node() if (c) fprintf(stderr, "%c", c); else - fprintf(stderr, ci->nm.contents()); + fputs(ci->nm.contents(), stderr); if (push_state) fprintf(stderr, " "); if (state) diff --git a/contrib/groff/src/utils/hpftodit/hpftodit.cpp b/contrib/groff/src/utils/hpftodit/hpftodit.cpp index 5910fb2f39e6..d5d524fdf1b2 100644 --- a/contrib/groff/src/utils/hpftodit/hpftodit.cpp +++ b/contrib/groff/src/utils/hpftodit/hpftodit.cpp @@ -870,9 +870,9 @@ output_charset(const int tfm_type) else if (!all_flag) continue; else if (tfm_type == MSL) - printf(hp_msl_to_ucode_name(charcode)); + fputs(hp_msl_to_ucode_name(charcode), stdout); else - printf(unicode_to_ucode_name(charcode)); + fputs(unicode_to_ucode_name(charcode), stdout); printf("\t%d,%d", scale(char_table[i].width), scale(char_table[i].ascent));