From: Florian Krohm Date: Thu, 13 Sep 2012 20:21:42 +0000 (+0000) Subject: Constify the format string in a few printf-like functions. X-Git-Tag: svn/VALGRIND_3_9_0^2~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=790951f64b0b54f142cf873e5c6bb383209f2589;p=thirdparty%2Fvalgrind.git Constify the format string in a few printf-like functions. git-svn-id: svn://svn.valgrind.org/vex/trunk@2530 --- diff --git a/VEX/priv/host_s390_disasm.c b/VEX/priv/host_s390_disasm.c index a23009e539..ccccddee9f 100644 --- a/VEX/priv/host_s390_disasm.c +++ b/VEX/priv/host_s390_disasm.c @@ -36,10 +36,8 @@ #include "main_globals.h" // vex_traceflags #include "host_s390_disasm.h" -/* The format that is used to write out a mnemonic. - These should be declared as 'const HChar' but vex_printf needs - to be changed for that first */ -static HChar s390_mnm_fmt[] = "%-8s"; +/* The format that is used to write out a mnemonic. */ +static const HChar s390_mnm_fmt[] = "%-8s"; /* Return the name of a general purpose register for dis-assembly purposes. */ diff --git a/VEX/priv/main_util.c b/VEX/priv/main_util.c index b4ca7beac6..6f5fc1c09b 100644 --- a/VEX/priv/main_util.c +++ b/VEX/priv/main_util.c @@ -220,7 +220,7 @@ void vex_assert_fail ( const HChar* expr, } __attribute__ ((noreturn)) -void vpanic ( HChar* str ) +void vpanic ( const HChar* str ) { vex_printf("\nvex: the `impossible' happened:\n %s\n", str); (*vex_failure_exit)(); @@ -316,7 +316,7 @@ void convert_int ( /*OUT*/HChar* buf, Long n0, printf. */ static UInt vprintf_wrk ( void(*sink)(HChar), - HChar* format, + const HChar* format, va_list ap ) { # define PUT(_ch) \ @@ -331,7 +331,7 @@ UInt vprintf_wrk ( void(*sink)(HChar), do { HChar* _qq = _str; for (; *_qq; _qq++) PUT(*_qq); } \ while (0) - HChar* saved_format; + const HChar* saved_format; Bool longlong, ljustify; HChar padchar; Int fwidth, nout, len1, len2, len3; @@ -494,7 +494,7 @@ static void add_to_myprintf_buf ( HChar c ) } } -UInt vex_printf ( HChar* format, ... ) +UInt vex_printf ( const HChar* format, ... ) { UInt ret; va_list vargs; @@ -523,7 +523,7 @@ static void add_to_vg_sprintf_buf ( HChar c ) *vg_sprintf_ptr++ = c; } -UInt vex_sprintf ( HChar* buf, HChar *format, ... ) +UInt vex_sprintf ( HChar* buf, const HChar *format, ... ) { Int ret; va_list vargs; diff --git a/VEX/priv/main_util.h b/VEX/priv/main_util.h index bee6649257..ce5aa005c0 100644 --- a/VEX/priv/main_util.h +++ b/VEX/priv/main_util.h @@ -60,16 +60,16 @@ __attribute__ ((__noreturn__)) extern void vex_assert_fail ( const HChar* expr, const HChar* file, Int line, const HChar* fn ); __attribute__ ((__noreturn__)) -extern void vpanic ( HChar* str ); +extern void vpanic ( const HChar* str ); /* Printing */ __attribute__ ((format (printf, 1, 2))) -extern UInt vex_printf ( HChar *format, ... ); +extern UInt vex_printf ( const HChar *format, ... ); __attribute__ ((format (printf, 2, 3))) -extern UInt vex_sprintf ( HChar* buf, HChar *format, ... ); +extern UInt vex_sprintf ( HChar* buf, const HChar *format, ... ); /* String ops */