diff options
author | Guy Harris <guy@alum.mit.edu> | 2010-05-26 02:25:13 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2010-05-26 02:25:13 +0000 |
commit | 347e7a0052fe0610ec105de34efe935c727fd3ce (patch) | |
tree | 53fd93c58d394cdf6782babb1b96014b926a8509 | |
parent | 7da29cfe69d37b0e601d13546fd667739f581dbe (diff) | |
download | wireshark-347e7a0052fe0610ec105de34efe935c727fd3ce.tar.gz |
More <stdarg.h> cleanup; some are real bugs, some are just "don't do
va_start and va_end unless you're actually going to use the va_list"
(those bring the va_start and va_end closer to the use point, which
makes it a little more obvious that we're using <stdarg.h> correctly and
makes it a little harder to use it incorrectly).
svn path=/trunk/; revision=32963
-rw-r--r-- | epan/dissectors/dcerpc/idl2wrs.c | 10 | ||||
-rw-r--r-- | epan/proto.c | 12 | ||||
-rw-r--r-- | tools/lemon/lemon.c | 2 | ||||
-rw-r--r-- | trigcap.c | 4 |
4 files changed, 17 insertions, 11 deletions
diff --git a/epan/dissectors/dcerpc/idl2wrs.c b/epan/dissectors/dcerpc/idl2wrs.c index bccef64a0a..2eba2b2e32 100644 --- a/epan/dissectors/dcerpc/idl2wrs.c +++ b/epan/dissectors/dcerpc/idl2wrs.c @@ -105,13 +105,17 @@ static char line[1024]; static void FPRINTF(FILE *fh, const char *format, ...) { va_list args; - va_start(args, format); + #ifdef IDL2WRS_DEBUG + va_start(args, format); vfprintf (stderr, format, args); + va_end(args); #endif - if (fh) + if (fh) { + va_start(args, format); vfprintf (fh, format, args); - va_end(args); + va_end(args); + } } typedef struct _pointer_item_t { diff --git a/epan/proto.c b/epan/proto.c index 3864ae994e..81a1a57223 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1080,9 +1080,12 @@ proto_tree_add_debug_text(proto_tree *tree, const char *format, ...) pi = proto_tree_add_text_node(tree, NULL, 0, 0); - va_start(ap, format); - if (pi) + if (pi) { + va_start(ap, format); proto_tree_set_representation(pi, format, ap); + va_end(ap); + } + va_start(ap, format); vprintf(format, ap); va_end(ap); printf("\n"); @@ -3634,8 +3637,6 @@ proto_item_append_text(proto_item *pi, const char *format, ...) } if (!PROTO_ITEM_IS_HIDDEN(pi)) { - va_start(ap, format); - /* * If we don't already have a representation, * generate the default representation. @@ -3647,10 +3648,11 @@ proto_item_append_text(proto_item *pi, const char *format, ...) curlen = strlen(fi->rep->representation); if (ITEM_LABEL_LENGTH > curlen) { + va_start(ap, format); g_vsnprintf(fi->rep->representation + curlen, ITEM_LABEL_LENGTH - (gulong) curlen, format, ap); + va_end(ap); } - va_end(ap); } } diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index 0facd5bdc3..26961660ef 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -1333,7 +1333,6 @@ void ErrorMsg(const char *filename, int lineno, const char *format, ...) va_list ap; int end, restart, base; - va_start(ap, format); /* Prepare a prefix to be prepended to every output line */ if( lineno>0 ){ sprintf(prefix,"%.*s:%d: ",PREFIXLIMIT-10,filename,lineno); @@ -1344,6 +1343,7 @@ void ErrorMsg(const char *filename, int lineno, const char *format, ...) availablewidth = LINEWIDTH - prefixsize; /* Generate the error message */ + va_start(ap, format); vsprintf(errmsg,format,ap); va_end(ap); errmsgsize = (int) strlen(errmsg); @@ -49,12 +49,12 @@ static void panic(int err, const char* fmt, ...) { static void dprintf(int lev, const char* fmt, ...) { va_list ap; - va_start(ap,fmt); if (lev <= debug_level) { + va_start(ap,fmt); vfprintf(stderr,fmt,ap); + va_end(ap); fflush(stderr); } - va_end(ap); } |