forked from osmocom/wireshark
proto.c: fix field display test in hfinfo_number_value_format_display64()
While we are at it, let's use the FIELD_DISPLAY() macro everywhere. Bug: 14169 Change-Id: I685cb7eb4b9c52f836762c92baeb636570a6d12f Reviewed-on: https://code.wireshark.org/review/24285 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
This commit is contained in:
parent
0e85c0ad1e
commit
f8a1878202
42
epan/proto.c
42
epan/proto.c
|
@ -5807,7 +5807,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
hf_str_val = NULL;
|
||||
number = fvalue_get_uinteger(&finfo->value);
|
||||
|
||||
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_CUSTOM) {
|
||||
if (FIELD_DISPLAY(hfinfo->display) == BASE_CUSTOM) {
|
||||
gchar tmp[ITEM_LABEL_LENGTH];
|
||||
custom_fmt_func_t fmtfunc = (custom_fmt_func_t)hfinfo->strings;
|
||||
|
||||
|
@ -5830,7 +5830,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
offset_r += protoo_strlcpy(result+offset_r, number_out, size-offset_r);
|
||||
}
|
||||
|
||||
if (hf_str_val && (hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_NONE) {
|
||||
if (hf_str_val && FIELD_DISPLAY(hfinfo->display) == BASE_NONE) {
|
||||
g_snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
|
||||
} else {
|
||||
number_out = hfinfo_char_value_format(hfinfo, number_buf, number);
|
||||
|
@ -5856,7 +5856,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
(guint32) fvalue_get_sinteger(&finfo->value) :
|
||||
fvalue_get_uinteger(&finfo->value);
|
||||
|
||||
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_CUSTOM) {
|
||||
if (FIELD_DISPLAY(hfinfo->display) == BASE_CUSTOM) {
|
||||
gchar tmp[ITEM_LABEL_LENGTH];
|
||||
custom_fmt_func_t fmtfunc = (custom_fmt_func_t)hfinfo->strings;
|
||||
|
||||
|
@ -5885,7 +5885,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
offset_r += protoo_strlcpy(result+offset_r, number_out, size-offset_r);
|
||||
}
|
||||
|
||||
if (hf_str_val && (hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_NONE) {
|
||||
if (hf_str_val && FIELD_DISPLAY(hfinfo->display) == BASE_NONE) {
|
||||
g_snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
|
||||
} else {
|
||||
number_out = hfinfo_numeric_value_format(hfinfo, number_buf, number);
|
||||
|
@ -5909,7 +5909,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
(guint64) fvalue_get_sinteger64(&finfo->value) :
|
||||
fvalue_get_uinteger64(&finfo->value);
|
||||
|
||||
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_CUSTOM) {
|
||||
if (FIELD_DISPLAY(hfinfo->display) == BASE_CUSTOM) {
|
||||
gchar tmp[ITEM_LABEL_LENGTH];
|
||||
custom_fmt_func_64_t fmtfunc64 = (custom_fmt_func_64_t)hfinfo->strings;
|
||||
|
||||
|
@ -5936,7 +5936,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
offset_r += protoo_strlcpy(result+offset_r, number_out, size-offset_r);
|
||||
}
|
||||
|
||||
if (hf_str_val && (hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_NONE) {
|
||||
if (hf_str_val && FIELD_DISPLAY(hfinfo->display) == BASE_NONE) {
|
||||
g_snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
|
||||
} else {
|
||||
number_out = hfinfo_numeric_value_format64(hfinfo, number_buf, number64);
|
||||
|
@ -7437,7 +7437,7 @@ tmp_fld_check_assert(header_field_info *hfinfo)
|
|||
report those that have same value but different string. */
|
||||
if ((hfinfo->strings != NULL) &&
|
||||
!(hfinfo->display & BASE_RANGE_STRING) &&
|
||||
!((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_CUSTOM) &&
|
||||
!(FIELD_DISPLAY(hfinfo->display) == BASE_CUSTOM) &&
|
||||
(
|
||||
(hfinfo->type == FT_CHAR) ||
|
||||
(hfinfo->type == FT_UINT8) ||
|
||||
|
@ -7535,7 +7535,7 @@ tmp_fld_check_assert(header_field_info *hfinfo)
|
|||
* signed field to be displayed unsigned. (Else how would
|
||||
* we display negative values?)
|
||||
*/
|
||||
switch (hfinfo->display & FIELD_DISPLAY_E_MASK) {
|
||||
switch (FIELD_DISPLAY(hfinfo->display)) {
|
||||
case BASE_HEX:
|
||||
case BASE_OCT:
|
||||
case BASE_DEC_HEX:
|
||||
|
@ -7607,7 +7607,7 @@ tmp_fld_check_assert(header_field_info *hfinfo)
|
|||
* meaningless; we'll avoid showing the value to the
|
||||
* user.
|
||||
*/
|
||||
switch (hfinfo->display & FIELD_DISPLAY_E_MASK) {
|
||||
switch (FIELD_DISPLAY(hfinfo->display)) {
|
||||
case BASE_DEC:
|
||||
case BASE_HEX:
|
||||
case BASE_OCT:
|
||||
|
@ -9134,7 +9134,7 @@ hfinfo_char_value_format_display(int display, char buf[7], guint32 value)
|
|||
break;
|
||||
|
||||
default:
|
||||
switch (display & FIELD_DISPLAY_E_MASK) {
|
||||
switch (FIELD_DISPLAY(display)) {
|
||||
|
||||
case BASE_OCT:
|
||||
*(--ptr) = (value & 0x7) + '0';
|
||||
|
@ -9169,7 +9169,7 @@ hfinfo_number_value_format_display(const header_field_info *hfinfo, int display,
|
|||
|
||||
*ptr = '\0';
|
||||
/* Properly format value */
|
||||
switch (display & FIELD_DISPLAY_E_MASK) {
|
||||
switch (FIELD_DISPLAY(display)) {
|
||||
case BASE_DEC:
|
||||
return isint ? int_to_str_back(ptr, (gint32) value) : uint_to_str_back(ptr, value);
|
||||
|
||||
|
@ -9238,7 +9238,7 @@ hfinfo_number_value_format_display64(const header_field_info *hfinfo, int displa
|
|||
|
||||
*ptr = '\0';
|
||||
/* Properly format value */
|
||||
switch (display) {
|
||||
switch (FIELD_DISPLAY(display)) {
|
||||
case BASE_DEC:
|
||||
return isint ? int64_to_str_back(ptr, (gint64) value) : uint64_to_str_back(ptr, value);
|
||||
|
||||
|
@ -9304,7 +9304,7 @@ static const char *
|
|||
hfinfo_char_value_format(const header_field_info *hfinfo, char buf[32], guint32 value)
|
||||
{
|
||||
/* Get the underlying BASE_ value */
|
||||
int display = hfinfo->display & FIELD_DISPLAY_E_MASK;
|
||||
int display = FIELD_DISPLAY(hfinfo->display);
|
||||
|
||||
return hfinfo_char_value_format_display(display, buf, value);
|
||||
}
|
||||
|
@ -9313,7 +9313,7 @@ static const char *
|
|||
hfinfo_numeric_value_format(const header_field_info *hfinfo, char buf[32], guint32 value)
|
||||
{
|
||||
/* Get the underlying BASE_ value */
|
||||
int display = hfinfo->display & FIELD_DISPLAY_E_MASK;
|
||||
int display = FIELD_DISPLAY(hfinfo->display);
|
||||
|
||||
if (hfinfo->type == FT_FRAMENUM) {
|
||||
/*
|
||||
|
@ -9350,7 +9350,7 @@ static const char *
|
|||
hfinfo_numeric_value_format64(const header_field_info *hfinfo, char buf[64], guint64 value)
|
||||
{
|
||||
/* Get the underlying BASE_ value */
|
||||
int display = hfinfo->display & FIELD_DISPLAY_E_MASK;
|
||||
int display = FIELD_DISPLAY(hfinfo->display);
|
||||
|
||||
if (hfinfo->type == FT_FRAMENUM) {
|
||||
/*
|
||||
|
@ -9381,7 +9381,7 @@ static const char *
|
|||
hfinfo_char_vals_format(const header_field_info *hfinfo, char buf[32], guint32 value)
|
||||
{
|
||||
/* Get the underlying BASE_ value */
|
||||
int display = hfinfo->display & FIELD_DISPLAY_E_MASK;
|
||||
int display = FIELD_DISPLAY(hfinfo->display);
|
||||
|
||||
return hfinfo_char_value_format_display(display, buf, value);
|
||||
}
|
||||
|
@ -9390,7 +9390,7 @@ static const char *
|
|||
hfinfo_number_vals_format(const header_field_info *hfinfo, char buf[32], guint32 value)
|
||||
{
|
||||
/* Get the underlying BASE_ value */
|
||||
int display = hfinfo->display & FIELD_DISPLAY_E_MASK;
|
||||
int display = FIELD_DISPLAY(hfinfo->display);
|
||||
|
||||
if (display == BASE_NONE)
|
||||
return NULL;
|
||||
|
@ -9407,7 +9407,7 @@ static const char *
|
|||
hfinfo_number_vals_format64(const header_field_info *hfinfo, char buf[64], guint64 value)
|
||||
{
|
||||
/* Get the underlying BASE_ value */
|
||||
int display = hfinfo->display & FIELD_DISPLAY_E_MASK;
|
||||
int display = FIELD_DISPLAY(hfinfo->display);
|
||||
|
||||
if (display == BASE_NONE)
|
||||
return NULL;
|
||||
|
@ -9830,7 +9830,7 @@ proto_registrar_dump_values(void)
|
|||
units = NULL;
|
||||
|
||||
if (hfinfo->strings != NULL) {
|
||||
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) != BASE_CUSTOM &&
|
||||
if (FIELD_DISPLAY(hfinfo->display) != BASE_CUSTOM &&
|
||||
(hfinfo->type == FT_CHAR ||
|
||||
hfinfo->type == FT_UINT8 ||
|
||||
hfinfo->type == FT_UINT16 ||
|
||||
|
@ -9937,7 +9937,7 @@ proto_registrar_dump_values(void)
|
|||
vi = 0;
|
||||
while (range[vi].strptr) {
|
||||
/* Print in the proper base */
|
||||
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_HEX) {
|
||||
if (FIELD_DISPLAY(hfinfo->display) == BASE_HEX) {
|
||||
ws_debug_printf("R\t%s\t0x%x\t0x%x\t%s\n",
|
||||
hfinfo->abbrev,
|
||||
range[vi].value_min,
|
||||
|
@ -10198,7 +10198,7 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
|
|||
DISSECTOR_ASSERT(hfinfo);
|
||||
abbrev_len = (int) strlen(hfinfo->abbrev);
|
||||
|
||||
if (hfinfo->strings && (hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_NONE) {
|
||||
if (hfinfo->strings && FIELD_DISPLAY(hfinfo->display) == BASE_NONE) {
|
||||
const gchar *str = NULL;
|
||||
|
||||
switch (hfinfo->type) {
|
||||
|
|
Loading…
Reference in New Issue