Try to fix some buildbot warnings

Most interesting are:
 warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations]
 warning: ISO C forbids zero-size array [-Wpedantic]
 warning: ISO C90 doesn't support unnamed structs/unions [-Wpedantic]
 warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual
 warning: initializer element is not computable at load time [enabled by default]

Change-Id: I5573c6bdca856a304877d9bef643f8c0fa93cdaf
Reviewed-on: https://code.wireshark.org/review/3174
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
This commit is contained in:
Michal Labedzki 2014-07-23 12:26:05 +02:00
parent c1d6a4123a
commit 56a09d24dc
14 changed files with 112 additions and 129 deletions

View File

@ -1276,7 +1276,6 @@ dissect_btavdtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown direction %d ",
direction);
goto LABEL_data;
break;
}
l2cap_data = (btl2cap_data_t *) data;

View File

@ -154,7 +154,7 @@ dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
guint16 uuid_dst;
guint16 uuid_src;
guint16 response_message;
guint list_length;
guint16 list_length;
guint i_item;
proto_tree_add_item(tree, hf_btbnep_control_type, tvb, offset, 1, ENC_BIG_ENDIAN);
@ -203,7 +203,7 @@ dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
list_length = tvb_get_ntohs(tvb, offset);
offset += 2;
for (i_item = 0; i_item < list_length; i_item += 4) {
for (i_item = 0; i_item + 4 > i_item && i_item < list_length; i_item += 4) {
proto_tree_add_item(tree, hf_btbnep_network_type_start, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
@ -223,7 +223,7 @@ dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
list_length = tvb_get_ntohs(tvb, offset);
offset += 2;
for (i_item = 0; i_item < list_length; i_item += 12) {
for (i_item = 0; i_item + 12 > i_item && i_item < list_length; i_item += 12) {
proto_tree_add_item(tree, hf_btbnep_multicast_address_start, tvb, offset, 6, ENC_NA);
offset += 6;

View File

@ -4988,7 +4988,7 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guint8 length;
guint8 type;
guint8 data_size;
gint end_offset;
gint64 end_offset;
guint i_uuid;
data_size = tvb_length(tvb);

View File

@ -1237,6 +1237,7 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
tid_request_t *tid_request;
continuation_state_data_t *continuation_state_data;
wmem_tree_key_t key[12];
wmem_tree_t *subtree;
guint32 k_interface_id;
guint32 k_adapter_id;
guint32 k_chandle;
@ -1244,13 +1245,13 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
guint32 k_tid;
guint32 k_pdu_type;
guint32 k_frame_number;
guint8 *k_continuation_state;
guint32 *k_continuation_state_array;
guint8 *continuation_state;
guint32 interface_id;
guint32 adapter_id;
guint32 chandle;
guint32 psm;
guint32 frame_number;
guint32 *continuation_state_array;
if (new_tvb) *new_tvb = NULL;
@ -1330,14 +1331,10 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
if (tid_request->continuation_state_length > 0) {
/* fetch tid_request->continuation_state */
k_continuation_state = (guint8 *) wmem_alloc0(wmem_packet_scope(), 20);
k_continuation_state[0] = tid_request->continuation_state_length;
memcpy(&k_continuation_state[1], tid_request->continuation_state, tid_request->continuation_state_length);
continuation_state_array = (guint32 *) k_continuation_state;
k_continuation_state = (guint8 *) wmem_alloc0(wmem_packet_scope(), 20);
k_continuation_state[0] = tid_request->continuation_state_length;
memcpy(&k_continuation_state[1], tid_request->continuation_state, tid_request->continuation_state_length);
k_continuation_state_array = (guint32 *) wmem_alloc0(wmem_packet_scope(), 20);
continuation_state = (guint8 *) k_continuation_state_array;
continuation_state[0] = tid_request->continuation_state_length;
memcpy(&continuation_state[1], tid_request->continuation_state, tid_request->continuation_state_length);
k_interface_id = interface_id;
k_adapter_id = adapter_id;
@ -1357,15 +1354,15 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
key[4].length = 1;
key[4].key = &k_pdu_type;
key[5].length = 1;
key[5].key = (guint32 *) &k_continuation_state[0];
key[5].key = &k_continuation_state_array[0];
key[6].length = 1;
key[6].key = (guint32 *) &k_continuation_state[4];
key[6].key = &k_continuation_state_array[1];
key[7].length = 1;
key[7].key = (guint32 *) &k_continuation_state[8];
key[7].key = &k_continuation_state_array[2];
key[8].length = 1;
key[8].key = (guint32 *) &k_continuation_state[12];
key[8].key = &k_continuation_state_array[3];
key[9].length = 1;
key[9].key = (guint32 *) &k_continuation_state[16];
key[9].key = &k_continuation_state_array[4];
key[10].length = 1;
key[10].key = &k_frame_number;
key[11].length = 0;
@ -1377,11 +1374,11 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
continuation_state_data->chandle == chandle &&
continuation_state_data->psm == psm &&
continuation_state_data->pdu_type == tid_request->pdu_type &&
continuation_state_data->continuation_state[0] == continuation_state_array[0] &&
continuation_state_data->continuation_state[1] == continuation_state_array[1] &&
continuation_state_data->continuation_state[2] == continuation_state_array[2] &&
continuation_state_data->continuation_state[3] == continuation_state_array[3] &&
continuation_state_data->continuation_state[4] == continuation_state_array[4]) {
continuation_state_data->continuation_state[0] == k_continuation_state_array[0] &&
continuation_state_data->continuation_state[1] == k_continuation_state_array[1] &&
continuation_state_data->continuation_state[2] == k_continuation_state_array[2] &&
continuation_state_data->continuation_state[3] == k_continuation_state_array[3] &&
continuation_state_data->continuation_state[4] == k_continuation_state_array[4]) {
tid_request->data = (guint8 *) wmem_alloc(wmem_file_scope(), continuation_state_data->data_length + attribute_list_byte_count);
tid_request->data_length = continuation_state_data->data_length + attribute_list_byte_count;
memcpy(tid_request->data, continuation_state_data->data, continuation_state_data->data_length);
@ -1443,16 +1440,16 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
}
}
} else {
guint8 *continuation_state;
guint8 *continuation_state_buffer;
guint8 continuation_state_length;
guint8 *packet_scope_string;
continuation_state_length = tvb_get_guint8(tvb, offset);
offset++;
continuation_state = (guint8 *) wmem_alloc(wmem_file_scope(), continuation_state_length);
continuation_state_buffer = (guint8 *) wmem_alloc(wmem_file_scope(), continuation_state_length);
packet_scope_string = tvb_bytes_to_ep_str(tvb, offset, continuation_state_length);
memcpy(continuation_state, packet_scope_string, continuation_state_length);
memcpy(continuation_state_buffer, packet_scope_string, continuation_state_length);
if (!pinfo->fd->flags.visited) {
if (is_request) {
@ -1479,7 +1476,7 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
tid_request->pdu_type = pdu_type;
tid_request->continuation_state = continuation_state;
tid_request->continuation_state = continuation_state_buffer;
tid_request->continuation_state_length = continuation_state_length;
wmem_tree_insert32_array(tid_requests, key, tid_request);
@ -1494,22 +1491,16 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
if (tid_request->continuation_state_length > 0) {
/* fetch tid_request->continuation_state */
k_continuation_state = (guint8 *) wmem_alloc0(wmem_packet_scope(), 20);
k_continuation_state[0] = tid_request->continuation_state_length;
memcpy(&k_continuation_state[1], tid_request->continuation_state, tid_request->continuation_state_length);
continuation_state_array = (guint32 *) k_continuation_state;
k_continuation_state = (guint8 *) wmem_alloc0(wmem_packet_scope(), 20);
k_continuation_state[0] = tid_request->continuation_state_length;
memcpy(&k_continuation_state[1], tid_request->continuation_state, tid_request->continuation_state_length);
k_continuation_state_array = (guint32 *) wmem_alloc0(wmem_packet_scope(), 20);
continuation_state = (guint8 *) k_continuation_state_array;
continuation_state[0] = tid_request->continuation_state_length;
memcpy(&continuation_state[1], tid_request->continuation_state, tid_request->continuation_state_length);
k_interface_id = interface_id;
k_adapter_id = adapter_id;
k_chandle = chandle;
k_psm = psm;
k_pdu_type = tid_request->pdu_type;
k_frame_number = frame_number;
key[0].length = 1;
key[0].key = &k_interface_id;
@ -1522,31 +1513,21 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
key[4].length = 1;
key[4].key = &k_pdu_type;
key[5].length = 1;
key[5].key = (guint32 *) &k_continuation_state[0];
key[5].key = &k_continuation_state_array[0];
key[6].length = 1;
key[6].key = (guint32 *) &k_continuation_state[4];
key[6].key = &k_continuation_state_array[1];
key[7].length = 1;
key[7].key = (guint32 *) &k_continuation_state[8];
key[7].key = &k_continuation_state_array[2];
key[8].length = 1;
key[8].key = (guint32 *) &k_continuation_state[12];
key[8].key = &k_continuation_state_array[3];
key[9].length = 1;
key[9].key = (guint32 *) &k_continuation_state[16];
key[10].length = 1;
key[10].key = &k_frame_number;
key[11].length = 0;
key[11].key = NULL;
key[9].key = &k_continuation_state_array[4];
key[10].length = 0;
key[10].key = NULL;
continuation_state_data = (continuation_state_data_t *) wmem_tree_lookup32_array_le(continuation_states, key);
if (continuation_state_data && continuation_state_data->interface_id == interface_id &&
continuation_state_data->adapter_id == adapter_id &&
continuation_state_data->chandle == chandle &&
continuation_state_data->psm == psm &&
continuation_state_data->pdu_type == tid_request->pdu_type &&
continuation_state_data->continuation_state[0] == continuation_state_array[0] &&
continuation_state_data->continuation_state[1] == continuation_state_array[1] &&
continuation_state_data->continuation_state[2] == continuation_state_array[2] &&
continuation_state_data->continuation_state[3] == continuation_state_array[3] &&
continuation_state_data->continuation_state[4] == continuation_state_array[4]) {
subtree = (wmem_tree_t *) wmem_tree_lookup32_array(continuation_states, key);
continuation_state_data = (subtree) ? (continuation_state_data_t *) wmem_tree_lookup32_le(subtree, frame_number) : NULL;
if (continuation_state_data) {
tid_request->data = (guint8 *) wmem_alloc(wmem_file_scope(), continuation_state_data->data_length + attribute_list_byte_count);
tid_request->data_length = continuation_state_data->data_length + attribute_list_byte_count;
memcpy(tid_request->data, continuation_state_data->data, continuation_state_data->data_length);
@ -1563,14 +1544,10 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
if (record_handle) *record_handle = tid_request->record_handle;
/* save tid_request in continuation_state data */
k_continuation_state = (guint8 *) wmem_alloc0(wmem_packet_scope(), 20);
k_continuation_state[0] = continuation_state_length;
memcpy(&k_continuation_state[1], continuation_state, continuation_state_length);
continuation_state_array = (guint32 *) k_continuation_state;
k_continuation_state = (guint8 *) wmem_alloc0(wmem_packet_scope(), 20);
k_continuation_state[0] = continuation_state_length;
memcpy(&k_continuation_state[1], continuation_state, continuation_state_length);
k_continuation_state_array = (guint32 *) wmem_alloc0(wmem_packet_scope(), 20);
continuation_state = (guint8 *) k_continuation_state_array;
continuation_state[0] = continuation_state_length;
memcpy(&continuation_state[1], continuation_state_buffer, continuation_state_length);
k_interface_id = interface_id;
k_adapter_id = adapter_id;
@ -1590,15 +1567,15 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
key[4].length = 1;
key[4].key = &k_pdu_type;
key[5].length = 1;
key[5].key = (guint32 *) &k_continuation_state[0];
key[5].key = &k_continuation_state_array[0];
key[6].length = 1;
key[6].key = (guint32 *) &k_continuation_state[4];
key[6].key = &k_continuation_state_array[1];
key[7].length = 1;
key[7].key = (guint32 *) &k_continuation_state[8];
key[7].key = &k_continuation_state_array[2];
key[8].length = 1;
key[8].key = (guint32 *) &k_continuation_state[12];
key[8].key = &k_continuation_state_array[3];
key[9].length = 1;
key[9].key = (guint32 *) &k_continuation_state[16];
key[9].key = &k_continuation_state_array[4];
key[10].length = 1;
key[10].key = &k_frame_number;
key[11].length = 0;
@ -1610,11 +1587,11 @@ reassemble_continuation_state(tvbuff_t *tvb, packet_info *pinfo,
continuation_state_data->chandle = chandle;
continuation_state_data->psm = psm;
continuation_state_data->pdu_type = pdu_type;
continuation_state_data->continuation_state[0] = continuation_state_array[0];
continuation_state_data->continuation_state[1] = continuation_state_array[1];
continuation_state_data->continuation_state[2] = continuation_state_array[2];
continuation_state_data->continuation_state[3] = continuation_state_array[3];
continuation_state_data->continuation_state[4] = continuation_state_array[4];
continuation_state_data->continuation_state[0] = k_continuation_state_array[0];
continuation_state_data->continuation_state[1] = k_continuation_state_array[1];
continuation_state_data->continuation_state[2] = k_continuation_state_array[2];
continuation_state_data->continuation_state[3] = k_continuation_state_array[3];
continuation_state_data->continuation_state[4] = k_continuation_state_array[4];
continuation_state_data->data = tid_request->data;
continuation_state_data->data_length = tid_request->data_length;

View File

@ -79,7 +79,7 @@ typedef int (*tGETTER) (const gchar *frame, const gchar *token, tvbuff_t *tvb,
proto_tree *maintree, gint start_offset, packet_info *pinfo);
typedef struct {
GRegex *regex;
GRegex **regex;
const tGETTER *getters;
guint no_of_getters;
} dissect_info_t;
@ -206,7 +206,7 @@ static int dissect_logcat_text(tvbuff_t *tvb, proto_tree *tree, packet_info *pin
if (!g_regex_match(special_regex, frame, G_REGEX_MATCH_NOTEMPTY, NULL)) {
tokens = g_regex_split(dinfo->regex, frame, G_REGEX_MATCH_NOTEMPTY);
tokens = g_regex_split(*dinfo->regex, frame, G_REGEX_MATCH_NOTEMPTY);
if (NULL == tokens) return 0;
if (g_strv_length(tokens) != dinfo->no_of_getters + 2) {
proto_tree_add_expert(maintree, pinfo, &ei_malformed_token, tvb, offset, -1);
@ -229,7 +229,7 @@ static int dissect_logcat_text(tvbuff_t *tvb, proto_tree *tree, packet_info *pin
static int dissect_logcat_text_brief(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_) {
static const tGETTER getters[] = { get_priority, get_tag, get_pid, get_log };
dissect_info_t dinfo = { brief_regex, getters, array_length(getters) };
dissect_info_t dinfo = { &brief_regex, getters, array_length(getters) };
return dissect_logcat_text(tvb, tree, pinfo, &dinfo);
}
@ -237,7 +237,7 @@ static int dissect_logcat_text_brief(tvbuff_t *tvb, packet_info *pinfo, proto_tr
static int dissect_logcat_text_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_) {
static const tGETTER getters[] = { get_priority, get_tag, get_log };
dissect_info_t dinfo = { tag_regex, getters, array_length(getters) };
dissect_info_t dinfo = { &tag_regex, getters, array_length(getters) };
return dissect_logcat_text(tvb, tree, pinfo, &dinfo);
}
@ -245,7 +245,7 @@ static int dissect_logcat_text_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree
static int dissect_logcat_text_process(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_) {
static const tGETTER getters[] = { get_priority, get_pid, get_log };
dissect_info_t dinfo = { process_regex, getters, array_length(getters) };
dissect_info_t dinfo = { &process_regex, getters, array_length(getters) };
SET_ADDRESS(&pinfo->dst, AT_STRINGZ, 0, "");
SET_ADDRESS(&pinfo->src, AT_STRINGZ, 0, "");
@ -256,7 +256,7 @@ static int dissect_logcat_text_process(tvbuff_t *tvb, packet_info *pinfo, proto_
static int dissect_logcat_text_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_) {
static const tGETTER getters[] = { get_time, get_priority, get_tag, get_pid, get_log };
dissect_info_t dinfo = { time_regex, getters, array_length(getters) };
dissect_info_t dinfo = { &time_regex, getters, array_length(getters) };
return dissect_logcat_text(tvb, tree, pinfo, &dinfo);
}
@ -264,7 +264,7 @@ static int dissect_logcat_text_time(tvbuff_t *tvb, packet_info *pinfo, proto_tre
static int dissect_logcat_text_thread(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_) {
static const tGETTER getters[] = { get_priority, get_pid, get_tid, get_log };
dissect_info_t dinfo = { thread_regex, getters, array_length(getters) };
dissect_info_t dinfo = { &thread_regex, getters, array_length(getters) };
SET_ADDRESS(&pinfo->dst, AT_STRINGZ, 0, "");
SET_ADDRESS(&pinfo->src, AT_STRINGZ, 0, "");
@ -275,7 +275,7 @@ static int dissect_logcat_text_thread(tvbuff_t *tvb, packet_info *pinfo, proto_t
static int dissect_logcat_text_threadtime(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_) {
static const tGETTER getters[] = { get_time, get_pid, get_tid, get_priority, get_tag, get_log };
dissect_info_t dinfo = { threadtime_regex, getters, array_length(getters) };
dissect_info_t dinfo = { &threadtime_regex, getters, array_length(getters) };
return dissect_logcat_text(tvb, tree, pinfo, &dinfo);
}
@ -283,7 +283,7 @@ static int dissect_logcat_text_threadtime(tvbuff_t *tvb, packet_info *pinfo, pro
static int dissect_logcat_text_long(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_) {
static const tGETTER getters[] = { get_time, get_pid, get_tid, get_priority, get_tag, get_log };
dissect_info_t dinfo = { long_regex, getters, array_length(getters) };
dissect_info_t dinfo = { &long_regex, getters, array_length(getters) };
return dissect_logcat_text(tvb, tree, pinfo, &dinfo);
}

View File

@ -490,7 +490,7 @@ dissect_usb_audio_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tre
{
usb_conv_info_t *usb_conv_info;
proto_tree *tree = NULL;
guint offset;
gint offset;
guint length = tvb_length(tvb);
@ -515,7 +515,7 @@ dissect_usb_audio_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tre
offset = 0;
col_set_str(pinfo->cinfo, COL_INFO, "USB-MIDI Event Packets");
while (offset < length)
while (offset > 0 && (guint) offset < length)
{
dissect_usb_midi_event(tvb, pinfo, tree, parent_tree, offset);
offset += 4;

View File

@ -556,7 +556,6 @@ dissect_usb_com_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
case 0x01: /* Network Transfer Block */
case 0x02: /* Network Transfer Block (IP + DSS) */
return call_dissector_only(mbim_bulk_handle, tvb, pinfo, tree, NULL);
break;
default:
break;
}

View File

@ -1104,7 +1104,7 @@ get_usb_conv_info(conversation_t *conversation)
/* usb_conv_info_t contains some components that are valid only for one specific packet
clear_usb_conv_tmp_data() clears these components, it should be called
before we dissect a new packet */
void clear_usb_conv_tmp_data(usb_conv_info_t *usb_conv_info)
static void clear_usb_conv_tmp_data(usb_conv_info_t *usb_conv_info)
{
/* caller must have checked that usb_conv_info!= NULL */
@ -1597,7 +1597,7 @@ dissect_usb_string_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree,
if (!usb_trans_info->u.get_descriptor.index) {
/* list of languanges */
while(len>(offset-old_offset)) {
while (offset >= old_offset && len > (offset - old_offset)) {
/* wLANGID */
proto_tree_add_item(tree, hf_usb_wLANGID, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset+=2;

View File

@ -1510,10 +1510,8 @@ init_file_types_subtypes(void)
/* if subtype is WTAP_FILE_TYPE_SUBTYPE_UNKNOWN, then create a new subtype as well as register it, else replace the
existing entry in that spot */
int
wtap_register_file_type_subtypes(const struct file_type_subtype_info* fi, const int subtype)
{
struct file_type_subtype_info* finfo = NULL;
int wtap_register_file_type_subtypes(const struct file_type_subtype_info* fi, const int subtype) {
struct file_type_subtype_info* finfo;
init_file_types_subtypes();
if (!fi || !fi->name || !fi->short_name || subtype > wtap_num_file_types_subtypes) {
@ -1560,10 +1558,8 @@ wtap_register_file_type_subtypes(const struct file_type_subtype_info* fi, const
/* De-registers a file writer - they can never be removed from the GArray, but we can "clear" an entry.
*/
void
wtap_deregister_file_type_subtype(const int subtype)
{
struct file_type_subtype_info* finfo = NULL;
void wtap_deregister_file_type_subtype(const int subtype) {
struct file_type_subtype_info* finfo;
if (subtype < 0 || subtype >= wtap_num_file_types_subtypes) {
g_error("invalid file type to de-register");

View File

@ -1641,7 +1641,11 @@ gzwfile_write(GZWFILE_T state, const void *buf, guint len)
/* directly compress user buffer to file */
strm->avail_in = len;
#if ZLIB_CONST
strm->next_in = (z_const Bytef *)buf;
#else
strm->next_in = (Bytef *)buf;
#endif
state->pos += len;
if (gz_comp(state, Z_NO_FLUSH) == -1)
return 0;

View File

@ -50,7 +50,9 @@ static gint detect_version(wtap *wth, int *err, gchar **err_info)
struct logger_entry_v2 *log_entry_v2;
guint8 *buffer;
guint16 tmp;
guint8 *msg_payload, *msg_part, *msg_end;
guint8 *msg_payload;
guint8 *msg_part;
guint8 *msg_end;
guint16 msg_len;
/* 16-bit payload length */
@ -90,11 +92,11 @@ static gint detect_version(wtap *wth, int *err, gchar **err_info)
* version is in use. First assume the smallest msg. */
for (version = 1; version <= 2; ++version) {
if (version == 1) {
msg_payload = log_entry->msg;
msg_payload = (guint8 *) (log_entry + 1);
entry_len = sizeof(*log_entry) + payload_length;
} else if (version == 2) {
/* v2 is 4 bytes longer */
msg_payload = log_entry_v2->msg;
msg_payload = (guint8 *) (log_entry_v2 + 1);
entry_len = sizeof(*log_entry_v2) + payload_length;
if (hdr_size != sizeof(*log_entry_v2))
continue;
@ -137,18 +139,18 @@ static gint detect_version(wtap *wth, int *err, gchar **err_info)
}
gint logcat_exported_pdu_length(const guint8 *pd) {
guint16 *tag;
guint16 *tag_length;
gint length = 0;
const guint16 *tag;
const guint16 *tag_length;
gint length = 0;
tag = (guint16 *) pd;
tag = (const guint16 *) pd;
while(GINT16_FROM_BE(*tag)) {
tag_length = (guint16 *) (pd + 2);
tag_length = (const guint16 *) (pd + 2);
length += 2 + 2 + GINT16_FROM_BE(*tag_length);
pd += 2 + 2 + GINT16_FROM_BE(*tag_length);
tag = (guint16 *) pd;
tag = (const guint16 *) pd;
}
length += 2 + 2;

View File

@ -39,7 +39,7 @@ struct logger_entry {
gint32 tid; /* generating process's tid */
gint32 sec; /* seconds since Epoch */
gint32 nsec; /* nanoseconds */
char msg[0]; /* the entry's payload */
/* char msg[0]; *//* the entry's payload */
};
struct logger_entry_v2 {
@ -53,8 +53,8 @@ struct logger_entry_v2 {
/* v1: not present */
guint32 euid; /* v2: effective UID of logger */
guint32 lid; /* v3: log id of the payload */
};
char msg[0]; /* the entry's payload */
} id;
/* char msg[0]; *//* the entry's payload */
};
int logcat_open(wtap *wth, int *err, gchar **err_info);

View File

@ -56,16 +56,16 @@ static gchar get_priority(const guint8 priority) {
static gint buffered_detect_version(const guint8 *pd)
{
struct logger_entry *log_entry;
struct logger_entry_v2 *log_entry_v2;
const struct logger_entry *log_entry;
const struct logger_entry_v2 *log_entry_v2;
gint version;
guint8 *msg_payload = NULL;
const guint8 *msg_payload = NULL;
guint8 *msg_part;
guint8 *msg_end;
guint16 msg_len;
log_entry_v2 = (struct logger_entry_v2 *) pd;
log_entry = (struct logger_entry *) pd;
log_entry_v2 = (const struct logger_entry_v2 *) pd;
log_entry = (const struct logger_entry *) pd;
/* must contain at least priority and two nulls as separator */
if (log_entry->len < 3)
@ -79,10 +79,10 @@ static gint buffered_detect_version(const guint8 *pd)
* version is in use. First assume the smallest msg. */
for (version = 1; version <= 2; ++version) {
if (version == 1) {
msg_payload = log_entry->msg;
msg_payload = (const guint8 *) (log_entry + 1);
} else if (version == 2) {
/* v2 is 4 bytes longer */
msg_payload = log_entry_v2->msg;
msg_payload = (const guint8 *) (log_entry_v2 + 1);
if (log_entry_v2->hdr_size != sizeof(*log_entry_v2))
continue;
}
@ -427,6 +427,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh,
gint32 tid;
gint32 seconds;
gint32 milliseconds;
const guint8 *msg_payload = NULL;
const gchar *msg_begin;
gint msg_pre_skip;
gchar *log;
@ -458,8 +459,8 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh,
logcat_version = pseudo_header->logcat.version;
}
log_entry = (struct logger_entry *) pd;
log_entry_v2 = (struct logger_entry_v2 *) pd;
log_entry = (const struct logger_entry *) pd;
log_entry_v2 = (const struct logger_entry_v2 *) pd;
payload_length = GINT32_FROM_LE(log_entry->len);
pid = GINT32_FROM_LE(log_entry->pid);
@ -469,15 +470,19 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh,
/* msg: <prio:1><tag:N>\0<msg:N>\0 with N >= 0, last \0 can be missing */
if (logcat_version == 1) {
priority = get_priority(log_entry->msg[0]);
tag = log_entry->msg + 1;
msg_payload = (const guint8 *) (log_entry + 1);
priority = get_priority(msg_payload[0]);
tag = msg_payload + 1;
msg_pre_skip = 1 + (gint) strlen(tag) + 1;
msg_begin = log_entry->msg + msg_pre_skip;
msg_begin = msg_payload + msg_pre_skip;
} else if (logcat_version == 2) {
priority = get_priority(log_entry_v2->msg[0]);
tag = log_entry_v2->msg + 1;
msg_payload = (const guint8 *) (log_entry_v2 + 1);
priority = get_priority(msg_payload[0]);
tag = msg_payload + 1;
msg_pre_skip = 1 + (gint) strlen(tag) + 1;
msg_begin = log_entry_v2->msg + msg_pre_skip;
msg_begin = msg_payload + msg_pre_skip;
} else {
*err = WTAP_ERR_UNSUPPORTED;
return FALSE;
@ -533,7 +538,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh,
case WTAP_ENCAP_LOGCAT_THREADTIME:
case WTAP_ENCAP_LOGCAT_LONG:
if (dumper->type == wdh->encap) {
if (!wtap_dump_file_write(wdh, (gchar*) pd, phdr->caplen, err)) {
if (!wtap_dump_file_write(wdh, (const gchar*) pd, phdr->caplen, err)) {
return FALSE;
}
} else {

View File

@ -50,7 +50,8 @@ merge_open_in_files(int in_file_count, char *const *in_file_names,
merge_in_file_t **in_files, int *err, gchar **err_info,
int *err_fileno)
{
int i, j;
gint i;
gint j;
size_t files_size = in_file_count * sizeof(merge_in_file_t);
merge_in_file_t *files;
gint64 size;
@ -73,7 +74,7 @@ merge_open_in_files(int in_file_count, char *const *in_file_names,
}
size = wtap_file_size(files[i].wth, err);
if (size == -1) {
for (j = 0; j <= i; j++)
for (j = 0; j + 1 > j && j <= i; j++)
wtap_close(files[j].wth);
*err_fileno = i;
return FALSE;