diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-04-15 17:40:35 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-04-16 00:41:42 +0000 |
commit | abbf5202b46fe6cb57e30fbc5fb8afee1157a4de (patch) | |
tree | 0d6e2dbc8922649f03822e9baabafa0e8dd4b200 /epan | |
parent | cd958c7418bb66920488798c9f49ae4784bf9d77 (diff) |
Squelch some warnings:
The dictionary_id member of a spdy_conv_t is only used if we have libz;
put it inside the #ifdef. That also lets us give it a type of uLong,
from libz, which avoids it being 32 bits when the type returned by
adler32() is 64 bits. (The *value returned by adler32()* might always
fit in 32 bits, but this is arguably cleaner than throwing a cast at the
problem.)
The third argument to adler32() is a uInt; cast sizeof to uInt to avoid
other 32-bit-vs-64-bit warnings. (It should have been size_t, but maybe
libz antedated size_t's availability in all the compilers that were used
to compile it.)
The buffer size in spdy_decompress_header_block() is always 16K; just
make it a #define that is *not* size_t, so that we avoid other
32-bit-vs-64-bit warnings.
Use DISSECTOR_ASSERT_NOT_REACHED() for "this can't happen" - it's marked
as "doesn't return", so we don't get "variable is unassigned" warnings
(at least not from the Clang I'm using), and also means we wouldn't get
a crash if it *does* happen (we just get a warning on the console and in
the protocol tree).
Change-Id: I55945b69b7485a02f3f623b21f671ed2915d453d
Reviewed-on: https://code.wireshark.org/review/1162
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-spdy.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/epan/dissectors/packet-spdy.c b/epan/dissectors/packet-spdy.c index 5c52c22632..d5ff22db0b 100644 --- a/epan/dissectors/packet-spdy.c +++ b/epan/dissectors/packet-spdy.c @@ -63,8 +63,8 @@ typedef struct _spdy_conv_t { #ifdef HAVE_LIBZ z_streamp rqst_decompressor; z_streamp rply_decompressor; + uLong dictionary_id; #endif - guint32 dictionary_id; wmem_tree_t *streams; } spdy_conv_t; @@ -469,7 +469,7 @@ static spdy_conv_t * get_or_create_spdy_conversation_data(packet_info *pinfo) { conv_data->dictionary_id = adler32(0L, Z_NULL, 0); conv_data->dictionary_id = adler32(conv_data->dictionary_id, spdy_dictionary, - sizeof(spdy_dictionary)); + (uInt)sizeof(spdy_dictionary)); #endif } @@ -938,20 +938,22 @@ body_dissected: * The returned buffer is automatically scoped to the lifetime of the capture * (via se_memdup()). */ +#define DECOMPRESS_BUFSIZE 16384 + static guint8* spdy_decompress_header_block(tvbuff_t *tvb, z_streamp decomp, - guint32 dictionary_id, + uLong dictionary_id, int offset, guint32 length, guint *uncomp_length) { int retcode; - size_t bufsize = 16384; const guint8 *hptr = tvb_get_ptr(tvb, offset, length); - guint8 *uncomp_block = (guint8 *)wmem_alloc(wmem_packet_scope(), bufsize); + guint8 *uncomp_block = (guint8 *)wmem_alloc(wmem_packet_scope(), DECOMPRESS_BUFSIZE); + decomp->next_in = (Bytef *)hptr; decomp->avail_in = length; decomp->next_out = uncomp_block; - decomp->avail_out = bufsize; + decomp->avail_out = DECOMPRESS_BUFSIZE; retcode = inflate(decomp, Z_SYNC_FLUSH); if (retcode == Z_NEED_DICT) { if (decomp->adler == dictionary_id) { @@ -970,7 +972,7 @@ static guint8* spdy_decompress_header_block(tvbuff_t *tvb, } /* Handle successful inflation. */ - *uncomp_length = bufsize - decomp->avail_out; + *uncomp_length = DECOMPRESS_BUFSIZE - decomp->avail_out; return (guint8 *)wmem_memdup(wmem_file_scope(), uncomp_block, *uncomp_length); } @@ -1146,7 +1148,7 @@ static int dissect_spdy_header_payload( decomp = conv_data->rply_decompressor; } else { /* Unhandled case. This should never happen. */ - g_assert(FALSE); + DISSECTOR_ASSERT_NOT_REACHED(); } /* Decompress. */ |