diff options
author | Michael Mann <mmann78@netscape.net> | 2016-07-24 08:53:39 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-07-25 04:26:50 +0000 |
commit | 1da1f945e2988080add4923dc2021753e3b2f7c1 (patch) | |
tree | 2839b66064e34ba99a6d031778330f20497b5e93 /wsutil | |
parent | ee7f9c33f63532bc69899a0750177756be53c0c1 (diff) | |
download | wireshark-1da1f945e2988080add4923dc2021753e3b2f7c1.tar.gz |
Fix checkAPI.pl warnings about printf
Many of the complaints from checkAPI.pl for use of printf are when its embedded
in an #ifdef and checkAPI isn't smart enough to figure that out.
The other (non-ifdef) use is dumping internal structures (which is a type of
debug functionality)
Add a "ws_debug_printf" macro for printf to pacify the warnings.
Change-Id: I63610e1adbbaf2feffb4ec9d4f817247d833f7fd
Reviewed-on: https://code.wireshark.org/review/16623
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/plugins.c | 3 | ||||
-rw-r--r-- | wsutil/sha1.c | 17 | ||||
-rw-r--r-- | wsutil/ws_printf.h | 8 |
3 files changed, 19 insertions, 9 deletions
diff --git a/wsutil/plugins.c b/wsutil/plugins.c index ec3800bdf0..8a390948f5 100644 --- a/wsutil/plugins.c +++ b/wsutil/plugins.c @@ -40,6 +40,7 @@ #include <wsutil/report_err.h> #include <wsutil/plugins.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ /* linked list of all plugins */ typedef struct _plugin { @@ -372,7 +373,7 @@ print_plugin_description(const char *name, const char *version, const char *description, const char *filename, void *user_data _U_) { - printf("%s\t%s\t%s\t%s\n", name, version, description, filename); + ws_debug_printf("%s\t%s\t%s\t%s\n", name, version, description, filename); } void diff --git a/wsutil/sha1.c b/wsutil/sha1.c index 3aaf557052..9b115d56b2 100644 --- a/wsutil/sha1.c +++ b/wsutil/sha1.c @@ -339,6 +339,7 @@ void sha1_hmac( const guint8 *key, guint32 keylen, const guint8 *buf, guint32 bu #include <stdlib.h> #include <stdio.h> #include <errno.h> +#include <wsutil/ws_printf.h> /* ws_debug_printf */ /* * those are the standard FIPS-180-1 test vectors @@ -369,11 +370,11 @@ int main( int argc, char *argv[] ) if( argc < 2 ) { - printf( "\n SHA-1 Validation Tests:\n\n" ); + ws_debug_printf( "\n SHA-1 Validation Tests:\n\n" ); for( i = 0; i < 3; i++ ) { - printf( " Test %d ", i + 1 ); + ws_debug_printf( " Test %d ", i + 1 ); sha1_starts( &ctx ); @@ -401,20 +402,20 @@ int main( int argc, char *argv[] ) if( memcmp( output, val[i], 40 ) ) { - printf( "failed!\n" ); + ws_debug_printf( "failed!\n" ); return( 1 ); } - printf( "passed.\n" ); + ws_debug_printf( "passed.\n" ); } - printf( "\n" ); + ws_debug_printf( "\n" ); } else { if( ! ( f = ws_fopen( argv[1], "rb" ) ) ) { - printf("fopen: %s", g_strerror(errno)); + ws_debug_printf("fopen: %s", g_strerror(errno)); return( 1 ); } @@ -429,10 +430,10 @@ int main( int argc, char *argv[] ) for( j = 0; j < SHA1_DIGEST_LEN; j++ ) { - printf( "%02x", sha1sum[j] ); + ws_debug_printf( "%02x", sha1sum[j] ); } - printf( " %s\n", argv[1] ); + ws_debug_printf( " %s\n", argv[1] ); } return( 0 ); diff --git a/wsutil/ws_printf.h b/wsutil/ws_printf.h index 1ee3bf69e6..d996d01c5e 100644 --- a/wsutil/ws_printf.h +++ b/wsutil/ws_printf.h @@ -93,6 +93,14 @@ ws_snprintf(char *buffer, size_t size_of_buffer, const char * format, ...) { va_end(argptr); } +/* This is intended to fool checkAPIs.pl for places that have "debugging" +(using printf) usually wrapped in an #ifdef, but checkAPIs.pl isn't smart +enough to figure that out. +Dissectors should still try to use proto_tree_add_debug_text when the +debugging context has a protocol tree. +*/ +#define ws_debug_printf printf + #ifdef __cplusplus } #endif /* __cplusplus */ |