From: Florian Krohm Date: Sun, 14 Oct 2012 00:16:28 +0000 (+0000) Subject: Char/ HChar cleanup: The various panic and printf-like functions X-Git-Tag: svn/VALGRIND_3_9_0~629 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=786e11050af55ecae265d10151811bfd7cfcde1e;p=thirdparty%2Fvalgrind.git Char/ HChar cleanup: The various panic and printf-like functions all take const HChar * arguments. __FILE__ and __func__ expand into string literals (or character arrays initialised by them), as do strings created by the preprocessor e.g. #stuff. This change reduces the number of warnings from 17000+ to ~5500 git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13039 --- diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c index 3d9482b243..93d333d357 100644 --- a/coregrind/m_libcassert.c +++ b/coregrind/m_libcassert.c @@ -216,7 +216,7 @@ void VG_(show_sched_status) ( void ) } __attribute__ ((noreturn)) -static void report_and_quit ( const Char* report, +static void report_and_quit ( const HChar* report, UnwindStartRegs* startRegsIN ) { Addr stacktop; @@ -267,13 +267,13 @@ static void report_and_quit ( const Char* report, VG_(exit)(1); } -void VG_(assert_fail) ( Bool isCore, const Char* expr, const Char* file, - Int line, const Char* fn, const HChar* format, ... ) +void VG_(assert_fail) ( Bool isCore, const HChar* expr, const HChar* file, + Int line, const HChar* fn, const HChar* format, ... ) { va_list vargs; Char buf[256]; - Char* component; - Char* bugs_to; + const HChar* component; + const HChar* bugs_to; static Bool entered = False; if (entered) @@ -310,7 +310,7 @@ void VG_(assert_fail) ( Bool isCore, const Char* expr, const Char* file, } __attribute__ ((noreturn)) -static void panic ( Char* name, Char* report, Char* str, +static void panic ( const HChar* name, const HChar* report, const HChar* str, UnwindStartRegs* startRegs ) { if (VG_(clo_xml)) @@ -319,23 +319,23 @@ static void panic ( Char* name, Char* report, Char* str, report_and_quit(report, startRegs); } -void VG_(core_panic_at) ( Char* str, UnwindStartRegs* startRegs ) +void VG_(core_panic_at) ( const HChar* str, UnwindStartRegs* startRegs ) { panic("valgrind", VG_BUGS_TO, str, startRegs); } -void VG_(core_panic) ( Char* str ) +void VG_(core_panic) ( const HChar* str ) { VG_(core_panic_at)(str, NULL); } -void VG_(tool_panic) ( Char* str ) +void VG_(tool_panic) ( const HChar* str ) { panic(VG_(details).name, VG_(details).bug_reports_to, str, NULL); } /* Print some helpful-ish text about unimplemented things, and give up. */ -void VG_(unimplemented) ( Char* msg ) +void VG_(unimplemented) ( const HChar* msg ) { if (VG_(clo_xml)) VG_(printf_xml)("\n"); @@ -359,4 +359,3 @@ void VG_(unimplemented) ( Char* msg ) /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ - diff --git a/coregrind/m_libcprint.c b/coregrind/m_libcprint.c index bfa348853c..1b91877e39 100644 --- a/coregrind/m_libcprint.c +++ b/coregrind/m_libcprint.c @@ -522,7 +522,7 @@ UInt VG_(fmsg) ( const HChar* format, ... ) return count; } -void VG_(fmsg_bad_option) ( HChar* opt, const HChar* format, ... ) +void VG_(fmsg_bad_option) ( const HChar* opt, const HChar* format, ... ) { va_list vargs; va_start(vargs,format); @@ -573,7 +573,7 @@ void VG_(err_missing_prog) ( void ) } __attribute__((noreturn)) -void VG_(err_config_error) ( Char* format, ... ) +void VG_(err_config_error) ( const HChar* format, ... ) { va_list vargs; va_start(vargs,format); diff --git a/coregrind/pub_core_libcassert.h b/coregrind/pub_core_libcassert.h index d86cbabde4..b7880d8140 100644 --- a/coregrind/pub_core_libcassert.h +++ b/coregrind/pub_core_libcassert.h @@ -61,13 +61,13 @@ 0))) __attribute__ ((__noreturn__)) -extern void VG_(core_panic) ( Char* str ); +extern void VG_(core_panic) ( const HChar* str ); __attribute__ ((__noreturn__)) -extern void VG_(core_panic_at) ( Char* str, UnwindStartRegs* ); +extern void VG_(core_panic_at) ( const HChar* str, UnwindStartRegs* ); /* Called when some unhandleable client behaviour is detected. Prints a msg and aborts. */ -extern void VG_(unimplemented) ( Char* msg ) +extern void VG_(unimplemented) ( const HChar* msg ) __attribute__((__noreturn__)); /* Show the state of all threads. Mostly for debugging V. */ diff --git a/coregrind/pub_core_libcprint.h b/coregrind/pub_core_libcprint.h index 4870771ce4..5de2dc5fa6 100644 --- a/coregrind/pub_core_libcprint.h +++ b/coregrind/pub_core_libcprint.h @@ -62,7 +62,7 @@ extern void VG_(err_missing_prog) ( void ); /* Similarly - complain and stop if there is some kind of config error. */ __attribute__((noreturn)) -extern void VG_(err_config_error) ( Char* format, ... ); +extern void VG_(err_config_error) ( const HChar* format, ... ); #endif // __PUB_CORE_LIBCPRINT_H diff --git a/include/pub_tool_libcassert.h b/include/pub_tool_libcassert.h index ea38c971b4..7a2c5bd3fa 100644 --- a/include/pub_tool_libcassert.h +++ b/include/pub_tool_libcassert.h @@ -33,17 +33,17 @@ #define tl_assert(expr) \ ((void) (LIKELY(expr) ? 0 : \ - (VG_(assert_fail) (/*isCore?*/False, (const Char*)#expr, \ - (const Char*)__FILE__, __LINE__, \ - (const Char*)__PRETTY_FUNCTION__, \ - (const HChar*)""), \ + (VG_(assert_fail) (/*isCore?*/False, #expr, \ + __FILE__, __LINE__, \ + __PRETTY_FUNCTION__, \ + ""), \ 0))) #define tl_assert2(expr, format, args...) \ ((void) (LIKELY(expr) ? 0 : \ - (VG_(assert_fail) (/*isCore?*/False, (const Char*)#expr, \ - (const Char*)__FILE__, __LINE__, \ - (const Char*)__PRETTY_FUNCTION__, \ + (VG_(assert_fail) (/*isCore?*/False, #expr, \ + __FILE__, __LINE__, \ + __PRETTY_FUNCTION__, \ format, ##args), \ 0))) @@ -52,11 +52,11 @@ extern void VG_(exit)( Int status ); /* Prints a panic message, appends newline and bug reporting info, aborts. */ __attribute__ ((__noreturn__)) -extern void VG_(tool_panic) ( Char* str ); +extern void VG_(tool_panic) ( const HChar* str ); __attribute__ ((__noreturn__)) -extern void VG_(assert_fail) ( Bool isCore, const Char* expr, const Char* file, - Int line, const Char* fn, +extern void VG_(assert_fail) ( Bool isCore, const HChar* expr, const HChar* file, + Int line, const HChar* fn, const HChar* format, ... ); #endif // __PUB_TOOL_LIBCBASSERT_H diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h index 0dc9224685..91a51b4ce6 100644 --- a/include/pub_tool_libcprint.h +++ b/include/pub_tool_libcprint.h @@ -116,7 +116,7 @@ extern UInt VG_(fmsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2); // an option was given an inappropriate argument. This function prints an // error message, then shuts down the entire system. __attribute__((noreturn)) -extern void VG_(fmsg_bad_option) ( HChar* opt, const HChar* format, ... ) +extern void VG_(fmsg_bad_option) ( const HChar* opt, const HChar* format, ... ) PRINTF_CHECK(2, 3); // This is used for messages that are interesting to the user: info about