Char/ HChar cleanup: The various panic and printf-like functions
authorflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Sun, 14 Oct 2012 00:16:28 +0000 (00:16 +0000)
committerflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Sun, 14 Oct 2012 00:16:28 +0000 (00:16 +0000)
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 a5019735-40e9-0310-863c-91ae7b9d1cf9

coregrind/m_libcassert.c
coregrind/m_libcprint.c
coregrind/pub_core_libcassert.h
coregrind/pub_core_libcprint.h
include/pub_tool_libcassert.h
include/pub_tool_libcprint.h

index 3d9482b243b3bca30068c139d4aa606affacd572..93d333d35793a2dd2e80e297e73e0c289517fa07 100644 (file)
@@ -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)("</valgrindoutput>\n");
@@ -359,4 +359,3 @@ void VG_(unimplemented) ( Char* msg )
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
 /*--------------------------------------------------------------------*/
-
index bfa348853ca294b185026e1a599ca2f75c2ced78..1b91877e395686205a58a40749449c4d3bd10a10 100644 (file)
@@ -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);
index d86cbabde4a807bc5d69fb8a73f64f313d331295..b7880d814030e9d99c4fd98961b5a5a0ccdb1cef 100644 (file)
                               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. */
index 4870771ce477b853c2236677e178b5f2e371dee4..5de2dc5fa6be234a59597846132f218fa7fb88f2 100644 (file)
@@ -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
 
index ea38c971b41ba9ff9c3c45366809a2772cbfcbe2..7a2c5bd3fa952d85de471dc385cf824ee4e9b97d 100644 (file)
 
 #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
index 0dc92246855f641788c008566cf4248b07cb2c26..91a51b4ce6813ffcd7e9aa00c84c94e28b38daa0 100644 (file)
@@ -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