Check for G_GINT64_MODIFIER in Wireshark as we do in Wiretap.
In all the places where a cast to "long long" or "unsigned long long" was done, use G_GINT64_MODIFIER and get rid of the cast, as 1) there's no guarantee that "%ll" works and 2) there's no guarantee that "long long" works (the latter definitely does *NOT* work with MSVC++; the former doesn't work with regular printf in MSVC++, but it might work with the GLib printf-based functions). svn path=/trunk/; revision=21978
This commit is contained in:
parent
2a5ff70caa
commit
d2ac4f7133
38
acinclude.m4
38
acinclude.m4
|
@ -1568,6 +1568,44 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
|
||||||
AC_SUBST(KRB5_LIBS)
|
AC_SUBST(KRB5_LIBS)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Check whether a given format can be used to print 64-bit integers
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([AC_WIRESHARK_CHECK_64BIT_FORMAT],
|
||||||
|
[
|
||||||
|
AC_MSG_CHECKING([whether %$1x can be used to format 64-bit integers])
|
||||||
|
AC_RUN_IFELSE(
|
||||||
|
[
|
||||||
|
AC_LANG_SOURCE(
|
||||||
|
[[
|
||||||
|
#include <glib.h>
|
||||||
|
#if GTK_MAJOR_VERSION >= 2
|
||||||
|
#include <glib/gprintf.h>
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
guint64 t = 1;
|
||||||
|
char strbuf[16+1];
|
||||||
|
g_snprintf(strbuf, sizeof strbuf, "%016$1x", t << 32);
|
||||||
|
if (strcmp(strbuf, "0000000100000000") == 0)
|
||||||
|
exit(0);
|
||||||
|
else
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_DEFINE(G_GINT64_MODIFIER, "$1", [Format modifier for printing 64-bit numbers])
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
$2
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
#
|
#
|
||||||
# AC_WIRESHARK_GCC_CFLAGS_CHECK
|
# AC_WIRESHARK_GCC_CFLAGS_CHECK
|
||||||
#
|
#
|
||||||
|
|
38
configure.in
38
configure.in
|
@ -1194,6 +1194,44 @@ AC_C_BIGENDIAN
|
||||||
# XXX - do we need this?
|
# XXX - do we need this?
|
||||||
AC_PROG_GCC_TRADITIONAL
|
AC_PROG_GCC_TRADITIONAL
|
||||||
|
|
||||||
|
#
|
||||||
|
# Does GLib define G_GINT64_MODIFIER?
|
||||||
|
#
|
||||||
|
AC_MSG_CHECKING([[whether glib.h defines the G_GINT64_MODIFIER macro]])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[
|
||||||
|
AC_LANG_SOURCE(
|
||||||
|
[[
|
||||||
|
#include <glib.h>
|
||||||
|
#if GTK_MAJOR_VERSION >= 2
|
||||||
|
#include <glib/gprintf.h>
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
char strbuf[16+1];
|
||||||
|
g_snprintf(strbuf, sizeof strbuf, "%" G_GINT64_MODIFIER "x\n", (gint64)1);
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
AC_WIRESHARK_CHECK_64BIT_FORMAT(ll,
|
||||||
|
[
|
||||||
|
AC_WIRESHARK_CHECK_64BIT_FORMAT(L,
|
||||||
|
[
|
||||||
|
AC_WIRESHARK_CHECK_64BIT_FORMAT(q,
|
||||||
|
[
|
||||||
|
AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
GETOPT_C=""
|
GETOPT_C=""
|
||||||
GETOPT_O=""
|
GETOPT_O=""
|
||||||
AC_CHECK_FUNC(getopt, GETOPT_O="",
|
AC_CHECK_FUNC(getopt, GETOPT_O="",
|
||||||
|
|
|
@ -1062,15 +1062,13 @@ pr_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
|
||||||
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 18);
|
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 18);
|
||||||
|
|
||||||
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
|
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
|
||||||
"CLOCK_BIAS: (%llu)",
|
"CLOCK_BIAS: (%" G_GINT64_MODIFIER "u)", temp_int);
|
||||||
(unsigned long long) temp_int);
|
|
||||||
|
|
||||||
offset = new_offset;
|
offset = new_offset;
|
||||||
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 16);
|
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 16);
|
||||||
|
|
||||||
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
|
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
|
||||||
"CLOCK_DRIFT: (%llu)",
|
"CLOCK_DRIFT: (%" G_GINT64_MODIFIER "u)", temp_int);
|
||||||
(unsigned long long) temp_int);
|
|
||||||
|
|
||||||
offset = new_offset;
|
offset = new_offset;
|
||||||
bit_mask = 0x80 >> (8 - bit_offset);
|
bit_mask = 0x80 >> (8 - bit_offset);
|
||||||
|
@ -1147,15 +1145,13 @@ pr_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
|
||||||
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 14);
|
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 14);
|
||||||
|
|
||||||
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
|
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
|
||||||
"HEIGHT: (%llu)",
|
"HEIGHT: (%" G_GINT64_MODIFIER "u)", temp_int);
|
||||||
(unsigned long long) temp_int);
|
|
||||||
|
|
||||||
offset = new_offset;
|
offset = new_offset;
|
||||||
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 5);
|
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 5);
|
||||||
|
|
||||||
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
|
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
|
||||||
"LOC_UNCRTNTY_V: (%llu)",
|
"LOC_UNCRTNTY_V: (%" G_GINT64_MODIFIER "u)", temp_int);
|
||||||
(unsigned long long) temp_int);
|
|
||||||
|
|
||||||
offset = new_offset;
|
offset = new_offset;
|
||||||
bit_mask = 0x80 >> (8 - bit_offset);
|
bit_mask = 0x80 >> (8 - bit_offset);
|
||||||
|
@ -1232,8 +1228,7 @@ for_pr_gps_sat_health(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset
|
||||||
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 5);
|
temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 5);
|
||||||
|
|
||||||
proto_tree_add_text(tree, tvb, offset, 1,
|
proto_tree_add_text(tree, tvb, offset, 1,
|
||||||
"BAD_SV_PRN_NUM: (%llu)",
|
"BAD_SV_PRN_NUM: (%" G_GINT64_MODIFIER "u)", temp_int);
|
||||||
(unsigned long long) temp_int);
|
|
||||||
|
|
||||||
offset = new_offset;
|
offset = new_offset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4525,7 +4525,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of
|
||||||
proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
|
proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
|
||||||
|
|
||||||
start_time = tvb_get_letoh64 (tvb, offset);
|
start_time = tvb_get_letoh64 (tvb, offset);
|
||||||
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_request_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016llX", (unsigned long long) start_time);
|
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_request_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
|
||||||
|
|
||||||
offset += 8;
|
offset += 8;
|
||||||
duration = tvb_get_letohs (tvb, offset);
|
duration = tvb_get_letohs (tvb, offset);
|
||||||
|
@ -4737,7 +4737,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
start_time = tvb_get_letoh64 (tvb, offset);
|
start_time = tvb_get_letoh64 (tvb, offset);
|
||||||
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016llX", (unsigned long long) start_time);
|
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
|
||||||
|
|
||||||
offset += 8;
|
offset += 8;
|
||||||
duration = tvb_get_letohs (tvb, offset);
|
duration = tvb_get_letohs (tvb, offset);
|
||||||
|
@ -4753,7 +4753,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
start_time = tvb_get_letoh64 (tvb, offset);
|
start_time = tvb_get_letoh64 (tvb, offset);
|
||||||
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016llX", (unsigned long long) start_time);
|
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
|
||||||
|
|
||||||
offset += 8;
|
offset += 8;
|
||||||
duration = tvb_get_letohs (tvb, offset);
|
duration = tvb_get_letohs (tvb, offset);
|
||||||
|
@ -4793,7 +4793,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
start_time = tvb_get_letoh64 (tvb, offset);
|
start_time = tvb_get_letoh64 (tvb, offset);
|
||||||
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016llX", (unsigned long long) start_time);
|
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
|
||||||
|
|
||||||
offset += 8;
|
offset += 8;
|
||||||
duration = tvb_get_letohs (tvb, offset);
|
duration = tvb_get_letohs (tvb, offset);
|
||||||
|
@ -4824,7 +4824,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
start_time = tvb_get_letoh64 (tvb, offset);
|
start_time = tvb_get_letoh64 (tvb, offset);
|
||||||
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016llX", (unsigned long long) start_time);
|
proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
|
||||||
|
|
||||||
offset += 8;
|
offset += 8;
|
||||||
duration = tvb_get_letohs (tvb, offset);
|
duration = tvb_get_letohs (tvb, offset);
|
||||||
|
|
|
@ -1536,7 +1536,7 @@ emem_tree_print_nodes(emem_tree_node_t* node, int level)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("NODE:%08x parent:%08x left:0x%08x right:%08x key:%d data:0x%08x\n",(int)(long)node,(int)(long)node->parent,(int)(long)node->left,(int)(long)node->right,node->key32,(int)(long)node->data);
|
printf("NODE:%p parent:%p left:0x%p right:%px key:%d data:%p\n",node,node->parent,node->left,node->right,node->key32,node->data);
|
||||||
if(node->left)
|
if(node->left)
|
||||||
emem_tree_print_nodes(node->left, level+1);
|
emem_tree_print_nodes(node->left, level+1);
|
||||||
if(node->right)
|
if(node->right)
|
||||||
|
@ -1548,7 +1548,7 @@ emem_print_tree(emem_tree_t* emem_tree)
|
||||||
if (!emem_tree)
|
if (!emem_tree)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printf("EMEM tree type:%d name:%s tree:0x%08x\n",emem_tree->type,emem_tree->name,(int)(long)emem_tree->tree);
|
printf("EMEM tree type:%d name:%s tree:%p\n",emem_tree->type,emem_tree->name,emem_tree->tree);
|
||||||
if(emem_tree->tree)
|
if(emem_tree->tree)
|
||||||
emem_tree_print_nodes(emem_tree->tree, 0);
|
emem_tree_print_nodes(emem_tree->tree, 0);
|
||||||
}
|
}
|
||||||
|
|
12
epan/proto.c
12
epan/proto.c
|
@ -507,7 +507,7 @@ proto_tree_free(proto_tree *tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_GPtrArray_value(gpointer key _U_, gpointer value, gpointer user_data _U_)
|
free_GPtrArray_value(gpointer key, gpointer value, gpointer user_data _U_)
|
||||||
{
|
{
|
||||||
GPtrArray *ptrs = value;
|
GPtrArray *ptrs = value;
|
||||||
gint hfid = (gint)(long)key;
|
gint hfid = (gint)(long)key;
|
||||||
|
@ -5768,15 +5768,13 @@ proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint
|
||||||
switch(hf_field->display){
|
switch(hf_field->display){
|
||||||
case BASE_DEC:
|
case BASE_DEC:
|
||||||
return proto_tree_add_uint64_format(tree, hf_index, tvb, offset, length, value,
|
return proto_tree_add_uint64_format(tree, hf_index, tvb, offset, length, value,
|
||||||
"%s: %llu",
|
"%s: %" G_GINT64_MODIFIER "u",
|
||||||
str,
|
str, value);
|
||||||
(unsigned long long) value);
|
|
||||||
break;
|
break;
|
||||||
case BASE_HEX:
|
case BASE_HEX:
|
||||||
return proto_tree_add_uint64_format(tree, hf_index, tvb, offset, length, value,
|
return proto_tree_add_uint64_format(tree, hf_index, tvb, offset, length, value,
|
||||||
"%s: 0x%llx",
|
"%s: 0x%" G_GINT64_MODIFIER "x",
|
||||||
str,
|
str, value);
|
||||||
(unsigned long long) value);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DISSECTOR_ASSERT_NOT_REACHED();
|
DISSECTOR_ASSERT_NOT_REACHED();
|
||||||
|
|
|
@ -111,7 +111,7 @@ gsm_map_stat_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
add_string_to_box(string_buff, file_box);
|
add_string_to_box(string_buff, file_box);
|
||||||
|
|
||||||
/* length */
|
/* length */
|
||||||
g_snprintf(string_buff, SUM_STR_MAX, "Length: %lld", (long long) summary.file_length);
|
g_snprintf(string_buff, SUM_STR_MAX, "Length: %" G_GINT64_MODIFIER "d", summary.file_length);
|
||||||
add_string_to_box(string_buff, file_box);
|
add_string_to_box(string_buff, file_box);
|
||||||
|
|
||||||
/* format */
|
/* format */
|
||||||
|
|
18
gtk/main.c
18
gtk/main.c
|
@ -1430,11 +1430,11 @@ set_display_filename(capture_file *cf)
|
||||||
|
|
||||||
/* convert file size */
|
/* convert file size */
|
||||||
if (cf->f_datalen/1024/1024 > 10) {
|
if (cf->f_datalen/1024/1024 > 10) {
|
||||||
size_str = g_strdup_printf("%lld MB", (long long) cf->f_datalen/1024/1024);
|
size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d MB", cf->f_datalen/1024/1024);
|
||||||
} else if (cf->f_datalen/1024 > 10) {
|
} else if (cf->f_datalen/1024 > 10) {
|
||||||
size_str = g_strdup_printf("%lld KB", (long long) cf->f_datalen/1024);
|
size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d KB", cf->f_datalen/1024);
|
||||||
} else {
|
} else {
|
||||||
size_str = g_strdup_printf("%lld Bytes", (long long) cf->f_datalen);
|
size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d Bytes", cf->f_datalen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* statusbar */
|
/* statusbar */
|
||||||
|
@ -1704,20 +1704,20 @@ main_cf_cb_live_capture_update_continue(capture_file *cf)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (cf->f_datalen/1024/1024 > 10) {
|
if (cf->f_datalen/1024/1024 > 10) {
|
||||||
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %lld MB",
|
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d MB",
|
||||||
get_interface_descriptive_name(capture_opts->iface),
|
get_interface_descriptive_name(capture_opts->iface),
|
||||||
capture_opts->save_file,
|
capture_opts->save_file,
|
||||||
(long long) cf->f_datalen/1024/1024);
|
cf->f_datalen/1024/1024);
|
||||||
} else if (cf->f_datalen/1024 > 10) {
|
} else if (cf->f_datalen/1024 > 10) {
|
||||||
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %lld KB",
|
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d KB",
|
||||||
get_interface_descriptive_name(capture_opts->iface),
|
get_interface_descriptive_name(capture_opts->iface),
|
||||||
capture_opts->save_file,
|
capture_opts->save_file,
|
||||||
(long long) cf->f_datalen/1024);
|
cf->f_datalen/1024);
|
||||||
} else {
|
} else {
|
||||||
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %lld Bytes",
|
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d Bytes",
|
||||||
get_interface_descriptive_name(capture_opts->iface),
|
get_interface_descriptive_name(capture_opts->iface),
|
||||||
capture_opts->save_file,
|
capture_opts->save_file,
|
||||||
(long long) cf->f_datalen);
|
cf->f_datalen);
|
||||||
}
|
}
|
||||||
|
|
||||||
statusbar_push_file_msg(capture_msg);
|
statusbar_push_file_msg(capture_msg);
|
||||||
|
|
|
@ -276,7 +276,7 @@ mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
add_string_to_box(string_buff, file_box);
|
add_string_to_box(string_buff, file_box);
|
||||||
|
|
||||||
/* length */
|
/* length */
|
||||||
g_snprintf(string_buff, SUM_STR_MAX, "Length: %lld", (long long) summary.file_length);
|
g_snprintf(string_buff, SUM_STR_MAX, "Length: %" G_GINT64_MODIFIER "d", summary.file_length);
|
||||||
add_string_to_box(string_buff, file_box);
|
add_string_to_box(string_buff, file_box);
|
||||||
|
|
||||||
/* format */
|
/* format */
|
||||||
|
|
|
@ -144,7 +144,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
add_string_to_table(table, &row, "Name:", string_buff);
|
add_string_to_table(table, &row, "Name:", string_buff);
|
||||||
|
|
||||||
/* length */
|
/* length */
|
||||||
g_snprintf(string_buff, SUM_STR_MAX, "%lld bytes", (long long) summary.file_length);
|
g_snprintf(string_buff, SUM_STR_MAX, "%" G_GINT64_MODIFIER "d bytes", summary.file_length);
|
||||||
add_string_to_table(table, &row, "Length:", string_buff);
|
add_string_to_table(table, &row, "Length:", string_buff);
|
||||||
|
|
||||||
/* format */
|
/* format */
|
||||||
|
|
Loading…
Reference in New Issue