Fix shadow variable warnings, fix type error.
Sadly, index() is still defined to be a function in some UN*Xes, for backwards compatibility with V7, where the function now known as strchr() was called index(); pick another name for variables named "index". wmem_array_get_count() returns a guint; store its value in a guint. That also means its return value is never negative. Change-Id: I357dcda9297f242355ef1ad8d2f1f192a0b5bb5f Reviewed-on: https://code.wireshark.org/review/34132 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
679ae4c1e3
commit
a0cdb06aba
|
@ -72,7 +72,7 @@ struct bitstring {
|
||||||
|
|
||||||
/* The index in source from which the next set of bits will be pulled
|
/* The index in source from which the next set of bits will be pulled
|
||||||
* when the bits in mask have been consumed */
|
* when the bits in mask have been consumed */
|
||||||
guint32 index;
|
guint32 bitstring_index;
|
||||||
|
|
||||||
/* Stores the next bits to be consumed in the bit string */
|
/* Stores the next bits to be consumed in the bit string */
|
||||||
guint32 mask;
|
guint32 mask;
|
||||||
|
@ -210,18 +210,18 @@ static int PrefixCodeTreeRebuild( struct hf_tree *tree,
|
||||||
*/
|
*/
|
||||||
static void bitstring_init(struct bitstring *bstr,
|
static void bitstring_init(struct bitstring *bstr,
|
||||||
const struct input *input,
|
const struct input *input,
|
||||||
guint32 index)
|
guint32 bitstring_index)
|
||||||
{
|
{
|
||||||
bstr->mask = tvb_get_letohs(input->tvb, input->offset+index);
|
bstr->mask = tvb_get_letohs(input->tvb, input->offset+bitstring_index);
|
||||||
bstr->mask <<= sizeof(bstr->mask) * 8 - 16;
|
bstr->mask <<= sizeof(bstr->mask) * 8 - 16;
|
||||||
index += 2;
|
bitstring_index += 2;
|
||||||
|
|
||||||
bstr->mask += tvb_get_letohs(input->tvb, input->offset+index);
|
bstr->mask += tvb_get_letohs(input->tvb, input->offset+bitstring_index);
|
||||||
index += 2;
|
bitstring_index += 2;
|
||||||
|
|
||||||
bstr->bits = 32;
|
bstr->bits = 32;
|
||||||
bstr->input = input;
|
bstr->input = input;
|
||||||
bstr->index = index;
|
bstr->bitstring_index = bitstring_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,9 +245,9 @@ static void bitstring_skip(struct bitstring *bstr, guint32 n)
|
||||||
|
|
||||||
if (bstr->bits < 16) {
|
if (bstr->bits < 16) {
|
||||||
bstr->mask += tvb_get_letohs(bstr->input->tvb,
|
bstr->mask += tvb_get_letohs(bstr->input->tvb,
|
||||||
bstr->input->offset + bstr->index)
|
bstr->input->offset + bstr->bitstring_index)
|
||||||
<< (16 - bstr->bits);
|
<< (16 - bstr->bits);
|
||||||
bstr->index = bstr->index + 2;
|
bstr->bitstring_index = bstr->bitstring_index + 2;
|
||||||
bstr->bits = bstr->bits + 16;
|
bstr->bits = bstr->bits + 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ static gboolean do_uncompress(struct input *input,
|
||||||
} else {
|
} else {
|
||||||
if (symbol == 256) {
|
if (symbol == 256) {
|
||||||
/* EOF symbol */
|
/* EOF symbol */
|
||||||
return bstr.index == bstr.input->size;
|
return bstr.bitstring_index == bstr.input->size;
|
||||||
}
|
}
|
||||||
symbol = symbol - 256;
|
symbol = symbol - 256;
|
||||||
length = symbol & 0xF;
|
length = symbol & 0xF;
|
||||||
|
@ -317,17 +317,17 @@ static gboolean do_uncompress(struct input *input,
|
||||||
match_offset *= -1;
|
match_offset *= -1;
|
||||||
|
|
||||||
if (length == 15) {
|
if (length == 15) {
|
||||||
if (bstr.index >= bstr.input->size)
|
if (bstr.bitstring_index >= bstr.input->size)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
length = tvb_get_guint8(bstr.input->tvb,
|
length = tvb_get_guint8(bstr.input->tvb,
|
||||||
bstr.input->offset+bstr.index) + 15;
|
bstr.input->offset+bstr.bitstring_index) + 15;
|
||||||
bstr.index += 1;
|
bstr.bitstring_index += 1;
|
||||||
|
|
||||||
if (length == 270) {
|
if (length == 270) {
|
||||||
if (bstr.index+1 >= bstr.input->size)
|
if (bstr.bitstring_index+1 >= bstr.input->size)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
length = tvb_get_letohs(bstr.input->tvb, bstr.input->offset+bstr.index);
|
length = tvb_get_letohs(bstr.input->tvb, bstr.input->offset+bstr.bitstring_index);
|
||||||
bstr.index += 2;
|
bstr.bitstring_index += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,11 +336,9 @@ static gboolean do_uncompress(struct input *input,
|
||||||
length += 3;
|
length += 3;
|
||||||
do {
|
do {
|
||||||
guint8 byte;
|
guint8 byte;
|
||||||
int index = wmem_array_get_count(obuf)+match_offset;
|
guint elem_count = wmem_array_get_count(obuf)+match_offset;
|
||||||
|
|
||||||
if (index < 0)
|
if (wmem_array_try_index(obuf, elem_count, &byte))
|
||||||
return FALSE;
|
|
||||||
if (wmem_array_try_index(obuf, index, &byte))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wmem_array_append_one(obuf, byte);
|
wmem_array_append_one(obuf, byte);
|
||||||
length--;
|
length--;
|
||||||
|
|
Loading…
Reference in New Issue