Fix some issues seen with cppcheck

This commit is contained in:
Martin Mathieson 2022-11-20 21:18:22 +00:00
parent ec353e89f3
commit 793365d0e0
20 changed files with 59 additions and 63 deletions

View File

@ -585,9 +585,9 @@ dissect_amqp_1_0_skip(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
proto_item *item _U_, int hf_amqp_type _U_);
static int
dissect_amqp_1_0_zero(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
guint offset _U_, guint length _U_,
proto_item *item _U_, int hf_amqp_type _U_);
dissect_amqp_1_0_zero(tvbuff_t *tvb, packet_info *pinfo,
guint offset, guint length _U_,
proto_item *item, int hf_amqp_type);
static int
dissect_amqp_1_0_true(tvbuff_t *tvb, packet_info *pinfo,
@ -601,8 +601,8 @@ dissect_amqp_1_0_false(tvbuff_t *tvb, packet_info *pinfo,
static int
format_amqp_1_0_null(tvbuff_t *tvb _U_,
guint offset, guint length _U_,
const char **value _U_);
guint offset _U_, guint length _U_,
const char **value);
static int
format_amqp_1_0_boolean_true(tvbuff_t *tvb, guint offset, guint length _U_,

View File

@ -4788,7 +4788,7 @@ static int decode_bgp_link_node_nlri_common_fields(tvbuff_t *tvb,
length -= dissected_length;
/* dissect Local Node Descriptors TLV */
if (length > 0 && length < 4) {
if (length < 4) {
expert_add_info_format(pinfo, tree, &ei_bgp_ls_error,
"Unknown data in Link-State Link NLRI! length = %d bytes", length);
return dissected_length;

View File

@ -4453,7 +4453,7 @@ dissect_dns_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
ext_tree = proto_tree_add_subtree_format(dns_tree, tvb, cur_off, extraneous_length,
ett_dns_extraneous, &it, "Extraneous Data (%d bytes)", extraneous_length);
it = proto_tree_add_item(ext_tree, hf_dns_extraneous_data, tvb, cur_off, extraneous_length, ENC_NA);
proto_tree_add_item(ext_tree, hf_dns_extraneous_data, tvb, cur_off, extraneous_length, ENC_NA);
it = proto_tree_add_int(ext_tree, hf_dns_extraneous_length, tvb, 0, 0, extraneous_length);
proto_item_set_generated(it);

View File

@ -426,7 +426,7 @@ dissect_dtpt_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree *dtpt_addrs_tree = NULL;
guint32 blob_rawsize = 0;
guint32 blob_size = 0;
guint32 blob_data_length = 0;
guint32 blob_data_length;
queryset_rawsize = tvb_get_letohl(tvb, offset + 0);
if (queryset_rawsize != 60) return 0;

View File

@ -2748,11 +2748,11 @@ static int decode_gtp_sig_pri_ind(tvbuff_t * tvb, int offset, packet_info * pinf
static int decode_gtp_sig_pri_ind_w_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_higher_br_16mb_flg(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_max_mbr_apn_ambr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_add_mm_ctx_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_add_mm_ctx_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_add_flgs_srvcc(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_stn_sr(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_c_msisdn(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_ext_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_ext_ranap_cause(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_ext_enodeb_id(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_ext_sel_mode_w_nsapi(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);
static int decode_gtp_ext_uli_timestamp(tvbuff_t * tvb, int offset, packet_info * pinfo _U_, proto_tree * tree, session_args_t * args _U_);

View File

@ -12,11 +12,11 @@ extern void dissect_gtpv2_ie_common(tvbuff_t* tvb, packet_info* pinfo _U_, proto
extern void dissect_gtpv2_mbms_service_area(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_mbms_session_duration(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_mbms_time_to_data_xfer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_mbms_time_to_data_xfer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_arp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_fq_csid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_selec_mode(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_epc_timer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_epc_timer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
extern void dissect_gtpv2_twan_identifier(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_);
/*Used by custom dissector*/
extern gchar* dissect_gtpv2_tai(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, gboolean is_5gs);

View File

@ -3982,7 +3982,6 @@ dissect_http_heur_tls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
return FALSE;
}
conv_data = get_http_conversation_data(pinfo, &conversation);
dissect_http_tls(tvb, pinfo, tree, data);
return TRUE;
}

View File

@ -4051,7 +4051,6 @@ proto_mpeg_descriptor_dissect_nordig_lcd_v2(tvbuff_t *tvb, guint offset, guint l
guint8 channel_list_id;
guint8 channel_list_name_length;
guint8 descriptor_length;
if (cnt < 1) return;
channel_list_id = tvb_get_guint8(tvb, offset);
channel_list_tree = proto_tree_add_subtree_format(tree, tvb, offset, ch_list_len,

View File

@ -4026,7 +4026,7 @@ de_nas_5gs_mm_extended_rejected_nssai(tvbuff_t* tvb, proto_tree* tree, packet_in
proto_tree* sub_partial_tree;
proto_tree* sub_rejected_tree;
proto_item* item;
int i = 1;
int i;
guint num_partial_items = 1;
guint32 curr_offset = offset;
guint32 type_of_list, number_of_element, nssai_len;
@ -10256,10 +10256,9 @@ dissect_nas_5gs_media_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
str = json_get_string(json_data, cur_tok, "contentId");
} else {
/* TS 29.502 ch6.1.6.4.4 n1SmInfoFromUe, n1SmInfoToUe, unknownN1SmInfo */
if (!cur_tok) {
cur_tok = json_get_object(json_data, tokens, N1_SMINFO_FROM_UE);
n1_msg_class = N1_SMINFO_FROM_UE;
}
cur_tok = json_get_object(json_data, tokens, N1_SMINFO_FROM_UE);
n1_msg_class = N1_SMINFO_FROM_UE;
if (!cur_tok) {
cur_tok = json_get_object(json_data, tokens, N1_SMINFO_TO_UE);
n1_msg_class = N1_SMINFO_TO_UE;

View File

@ -717,7 +717,7 @@ dissect_pvfs2_attrmask(tvbuff_t *tvb, proto_tree *tree, int offset,
for (i = 0; i < 32; i++)
{
if (attrmask & (1 << i))
if (attrmask & (1u << i))
proto_tree_add_uint(attrtree, hf_pvfs_attr, tvb, offset, 4, i);
}

View File

@ -662,7 +662,7 @@ dissect_sapms_adm_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gu
proto_item *record = NULL, *value = NULL;
proto_tree *record_tree = NULL, *value_tree = NULL;
guint8 adm_opcode = 0;
guint8 adm_opcode;
while (length>=104){

View File

@ -416,7 +416,7 @@ static int
dissect_saprouter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
tvbuff_t *next_tvb = NULL;
guint8 opcode = 0;
guint8 opcode;
guint32 offset = 0, eyecatcher_length = 0;
conversation_t *conversation = NULL;
saprouter_session_state *session_state = NULL;

View File

@ -1486,7 +1486,7 @@ dissect_rach_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint32 ft;
guint32 header_crc = 0;
proto_item * header_crc_pi = NULL;
guint header_length = 0;
guint header_length;
/* Header CRC */
header_crc_pi = proto_tree_add_item_ret_uint(tree, hf_fp_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN, &header_crc);
@ -1742,7 +1742,7 @@ dissect_fach_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint32 ft;
guint32 header_crc = 0;
proto_item * header_crc_pi = NULL;
guint header_length = 0;
guint header_length;
/* Header CRC */
header_crc_pi = proto_tree_add_item_ret_uint(tree, hf_fp_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN, &header_crc);
@ -2538,7 +2538,7 @@ dissect_dch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
{
guint32 ft;
guint32 cfn;
guint header_length = 0;
guint header_length;
guint32 header_crc = 0;
proto_item * header_crc_pi = NULL;
@ -2613,7 +2613,7 @@ dissect_e_dch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint32 header_crc = 0;
proto_item * header_crc_pi = NULL;
proto_item * item;
guint header_length = 0;
guint header_length;
rlc_info * rlcinf;
if (p_fp_info->edch_type == 1) {
@ -2645,7 +2645,7 @@ dissect_e_dch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
else {
/********************************/
/* E-DCH data here */
guint bit_offset = 0;
guint bit_offset;
guint total_pdus = 0;
guint total_bits = 0;
gboolean dissected = FALSE;
@ -3169,7 +3169,7 @@ dissect_hsdsch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, struct fp_info *p_fp_info, void *data)
{
guint32 ft;
guint header_length = 0;
guint header_length;
guint32 header_crc = 0;
proto_item * header_crc_pi = NULL;
@ -3388,7 +3388,7 @@ dissect_hsdsch_type_2_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree
guint32 ft;
guint32 header_crc = 0;
proto_item * header_crc_pi = NULL;
guint16 header_length = 0;
guint16 header_length;
/* Header CRC */
header_crc_pi = proto_tree_add_item_ret_uint(tree, hf_fp_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN, &header_crc);
@ -3649,7 +3649,7 @@ void dissect_hsdsch_common_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto
guint32 ft;
guint32 header_crc = 0;
proto_item * header_crc_pi = NULL;
guint header_length = 0;
guint header_length;
/* Header CRC */
header_crc_pi = proto_tree_add_item_ret_uint(tree, hf_fp_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN, &header_crc);

View File

@ -246,7 +246,7 @@ dissect_dlci_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, prot
"ISDN (%u)", efa);
proto_item_append_text(parameter_item, " (SAPI:%u TEI:%u EFA:ISDN (%u))",sapi,tei,efa);
}
else if (efa > 8175 && efa <= 8180){
else if (efa <= 8180){
proto_tree_add_uint_format_value(parameter_tree, hf_efa, parameter_tvb, offset, EFA_LENGTH, efa,
"%s (%u)", val_to_str_const(efa, efa_values, "unknown EFA"),tvb_get_ntohs(parameter_tvb, offset));
proto_item_append_text(parameter_item, " (SAPI:%u TEI:%u EFA:%s (%u))",sapi,tei,val_to_str_const(efa, efa_values, "unknown EFA-value"),efa);

View File

@ -132,7 +132,7 @@ tvb_new_chain(tvbuff_t *parent, tvbuff_t *backing)
void
tvb_add_to_chain(tvbuff_t *parent, tvbuff_t *child)
{
tvbuff_t *tmp = child;
tvbuff_t *tmp;
DISSECTOR_ASSERT(parent);
DISSECTOR_ASSERT(child);
@ -4208,7 +4208,7 @@ tvb_find_line_end_unquoted(tvbuff_t *tvb, const gint offset, int len, gint *next
gint
tvb_skip_wsp(tvbuff_t *tvb, const gint offset, const gint maxlength)
{
gint counter = offset;
gint counter;
gint end, tvb_len;
guint8 tempchar;
@ -4237,7 +4237,7 @@ tvb_skip_wsp(tvbuff_t *tvb, const gint offset, const gint maxlength)
gint
tvb_skip_wsp_return(tvbuff_t *tvb, const gint offset)
{
gint counter = offset;
gint counter;
guint8 tempchar;
DISSECTOR_ASSERT(tvb && tvb->initialized);

View File

@ -38,7 +38,7 @@ static gboolean do_uncompress(tvbuff_t *tvb, int offset, int in_size,
buf_flag_count = 32;
}
buf_flag_count--;
if ((buf_flags & (1 << buf_flag_count)) == 0) {
if ((buf_flags & (1u << buf_flag_count)) == 0) {
guint8 v = tvb_get_guint8(tvb, offset+in_off);
wmem_array_append_one(obuf, v);
in_off++;

View File

@ -819,10 +819,10 @@ parse_line(gchar *linebuff, gint line_length,
int n = 0;
int port_digits;
char port_number_string[MAX_PORT_DIGITS+1];
int variant_digits = 0;
int variant_digits;
int variant = 1;
int protocol_chars = 0;
int outhdr_chars = 0;
int protocol_chars;
int outhdr_chars;
char seconds_buff[MAX_SECONDS_CHARS+1];
int seconds_chars;

View File

@ -2202,7 +2202,7 @@ gzwfile_close(GZWFILE_T state)
int ret = 0;
/* flush, free memory, and close file */
if (gz_comp(state, Z_FINISH) == -1 && ret == 0)
if (gz_comp(state, Z_FINISH) == -1)
ret = state->err;
(void)deflateEnd(&(state->strm));
g_free(state->out);

View File

@ -267,15 +267,14 @@ wtap_open_return_val logcat_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_ERROR; /* I/O error */
if (tmp_version == 0)
return WTAP_OPEN_NOT_MINE; /* not a logcat file */
if (tmp_version != -2) {
/*
* we've read three packets and the first two have the same
* version; does the third have the same version?
*/
if (tmp_version != version) {
/* no, so this is presumably not a logcat file */
return WTAP_OPEN_NOT_MINE;
}
/*
* we've read three packets and the first two have the same
* version; does the third have the same version?
*/
if (tmp_version != version) {
/* no, so this is presumably not a logcat file */
return WTAP_OPEN_NOT_MINE;
}
}

View File

@ -3999,7 +3999,7 @@ static guint32 pcapng_compute_packet_verdict_option_size(wtap_optval_t *optval)
static gboolean
compute_block_option_size(wtap_block_t block _U_, guint option_id, wtap_opttype_e option_type, wtap_optval_t *optval, void *user_data)
{
compute_options_size_t* compute_options_size = (compute_options_size_t*)user_data;
compute_options_size_t* options_size = (compute_options_size_t*)user_data;
guint32 size = 0;
/*
@ -4027,7 +4027,7 @@ compute_block_option_size(wtap_block_t block _U_, guint option_id, wtap_opttype_
break;
default:
/* Block-type dependent; call the callback. */
size = (*compute_options_size->compute_option_size)(block, option_id, option_type, optval);
size = (*options_size->compute_option_size)(block, option_id, option_type, optval);
break;
}
@ -4039,15 +4039,15 @@ compute_block_option_size(wtap_block_t block _U_, guint option_id, wtap_opttype_
* Yes. Add the size of the option header to the size of the
* option data.
*/
compute_options_size->size += 4;
options_size->size += 4;
/* Now add the size of the option value. */
compute_options_size->size += size;
options_size->size += size;
/* Add optional padding to 32 bits */
if ((size & 0x03) != 0)
{
compute_options_size->size += 4 - (size & 0x03);
options_size->size += 4 - (size & 0x03);
}
}
return TRUE; /* we always succeed */
@ -4605,7 +4605,7 @@ static gboolean pcapng_write_packet_verdict_option(wtap_dumper *wdh, guint optio
static gboolean write_block_option(wtap_block_t block, guint option_id, wtap_opttype_e option_type _U_, wtap_optval_t *optval, void* user_data)
{
write_options_t* write_options = (write_options_t*)user_data;
write_options_t* options = (write_options_t*)user_data;
/*
* Process the option IDs that are the same for all block types here;
@ -4614,12 +4614,12 @@ static gboolean write_block_option(wtap_block_t block, guint option_id, wtap_opt
switch(option_id)
{
case OPT_COMMENT:
if (!pcapng_write_string_option(write_options->wdh, option_id, optval, write_options->err))
if (!pcapng_write_string_option(options->wdh, option_id, optval, options->err))
return FALSE;
break;
case OPT_CUSTOM_STR_COPY:
case OPT_CUSTOM_BIN_COPY:
if (!pcapng_write_custom_option(write_options->wdh, option_id, optval, write_options->err))
if (!pcapng_write_custom_option(options->wdh, option_id, optval, options->err))
return FALSE;
break;
case OPT_CUSTOM_STR_NO_COPY:
@ -4634,8 +4634,8 @@ static gboolean write_block_option(wtap_block_t block, guint option_id, wtap_opt
break;
default:
/* Block-type dependent; call the callback, if we have one. */
if (write_options->write_option != NULL &&
!(*write_options->write_option)(write_options->wdh, block, option_id, option_type, optval, write_options->err))
if (options->write_option != NULL &&
!(*options->write_option)(options->wdh, block, option_id, option_type, optval, options->err))
return FALSE;
break;
}
@ -4645,12 +4645,12 @@ static gboolean write_block_option(wtap_block_t block, guint option_id, wtap_opt
static gboolean
write_options(wtap_dumper *wdh, wtap_block_t block, write_option_func write_option, int *err)
{
write_options_t write_options;
write_options_t options;
write_options.wdh = wdh;
write_options.err = err;
write_options.write_option = write_option;
if (!wtap_block_foreach_option(block, write_block_option, &write_options))
options.wdh = wdh;
options.err = err;
options.write_option = write_option;
if (!wtap_block_foreach_option(block, write_block_option, &options))
return FALSE;
/* Write end of options */