]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
* document the %ps / %pS extensions to printf
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 7 May 2014 22:03:59 +0000 (22:03 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 7 May 2014 22:03:59 +0000 (22:03 +0000)
* remove (from memcheck) emiN, as PRINTF_CHECK can be done properly

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13942

include/pub_tool_libcprint.h
memcheck/mc_errors.c

index 70cd38143f3715e9b442e83e6f989fef556dd7e7..374d8e62cfa181cb08f6c2f412fe745fe8379221 100644 (file)
    Formatting functions
    ------------------------------------------------------------------ */
 
+/* The formatting functions supports a subset (and 2 extensions) of
+   the 'printf' format.
+   The extensions are:
+     %pS : print a string (like %s) but escaping chars for XML safety.
+     %ps : with --xml=no, synonym for %s, with --xml=yes, synonym of %pS.
+
+   Note: these extensions do not cause the compiler to barf with PRINTF_CHECK
+   as for the classical printf, %p requires a pointer, which must also
+   be provided for the %ps and %pS extensions. The s/S following %p
+   are understood by PRINTF_CHECK as characters to output.
+*/
+
 extern UInt VG_(sprintf)  ( HChar* buf, const HChar* format, ... )
                           PRINTF_CHECK(2, 3);
 
index 424e5129721b69f09b7a1d85b81e4fb475fc4292..6a03a50992d1a20d42ea533275f91d32d0306da0 100644 (file)
@@ -286,13 +286,6 @@ static void emit ( const HChar* format, ... )
    emit_WRK(format, vargs);
    va_end(vargs);
 }
-static void emiN ( const HChar* format, ... ) /* NO FORMAT CHECK */
-{
-   va_list vargs;
-   va_start(vargs, format);
-   emit_WRK(format, vargs);
-   va_end(vargs);
-}
 
 
 static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc )
@@ -371,7 +364,7 @@ static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc )
       }
 
       case Addr_DataSym:
-         emiN( "%sAddress 0x%llx is %llu bytes "
+         emit( "%sAddress 0x%llx is %llu bytes "
                "inside data symbol \"%pS\"%s\n",
                xpre,
                (ULong)a,
@@ -395,7 +388,7 @@ static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc )
          break;
 
       case Addr_SectKind:
-         emiN( "%sAddress 0x%llx is in the %pS segment of %pS%s\n",
+         emit( "%sAddress 0x%llx is in the %pS segment of %pS%s\n",
                xpre,
                (ULong)a,
                VG_(pp_SectKind)(ai->Addr.SectKind.kind),
@@ -589,7 +582,7 @@ void MC_(pp_Error) ( Error* err )
          // the following code is untested.  Bad.
          if (xml) {
             emit( "  <kind>CoreMemError</kind>\n" );
-            emiN( "  <what>%pS contains unaddressable byte(s)</what>\n",
+            emit( "  <what>%pS contains unaddressable byte(s)</what>\n",
                   VG_(get_error_string)(err));
             VG_(pp_ExeContext)( VG_(get_error_where)(err) );
          } else {
@@ -647,7 +640,7 @@ void MC_(pp_Error) ( Error* err )
          MC_(any_value_errors) = True;
          if (xml) {
             emit( "  <kind>SyscallParam</kind>\n" );
-            emiN( "  <what>Syscall param %pS contains "
+            emit( "  <what>Syscall param %pS contains "
                   "uninitialised byte(s)</what>\n",
                   VG_(get_error_string)(err) );
             VG_(pp_ExeContext)( VG_(get_error_where)(err) );
@@ -669,7 +662,7 @@ void MC_(pp_Error) ( Error* err )
             MC_(any_value_errors) = True;
          if (xml) {
             emit( "  <kind>SyscallParam</kind>\n" );
-            emiN( "  <what>Syscall param %pS points to %s byte(s)</what>\n",
+            emit( "  <what>Syscall param %pS points to %s byte(s)</what>\n",
                   VG_(get_error_string)(err),
                   extra->Err.MemParam.isAddrErr 
                      ? "unaddressable" : "uninitialised" );
@@ -797,7 +790,7 @@ void MC_(pp_Error) ( Error* err )
          if (xml) {
             emit( "  <kind>Overlap</kind>\n" );
             if (extra->Err.Overlap.szB == 0) {
-               emiN( "  <what>Source and destination overlap "
+               emit( "  <what>Source and destination overlap "
                      "in %pS(%#lx, %#lx)\n</what>\n",
                      VG_(get_error_string)(err),
                      extra->Err.Overlap.dst, extra->Err.Overlap.src );
@@ -811,7 +804,7 @@ void MC_(pp_Error) ( Error* err )
             VG_(pp_ExeContext)( VG_(get_error_where)(err) );
          } else {
             if (extra->Err.Overlap.szB == 0) {
-               emiN( "Source and destination overlap in %pS(%#lx, %#lx)\n",
+               emit( "Source and destination overlap in %pS(%#lx, %#lx)\n",
                      VG_(get_error_string)(err),
                      extra->Err.Overlap.dst, extra->Err.Overlap.src );
             } else {