Make some arguments const, and remove casting-away of constness.
Change-Id: Iaa43b4b355179a265975f67952feac819e79f7a6 Reviewed-on: https://code.wireshark.org/review/25957 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
1c5e6a1b34
commit
238550b9c5
18
epan/proto.c
18
epan/proto.c
|
@ -5965,7 +5965,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
double d_value = fvalue_get_floating(&finfo->value);
|
||||
g_snprintf(result+offset_r, size-offset_r,
|
||||
"%." G_STRINGIFY(FLT_DIG) "g%s", d_value,
|
||||
unit_name_string_get_double(d_value, (unit_name_string*)hfinfo->strings));
|
||||
unit_name_string_get_double(d_value, (const unit_name_string*)hfinfo->strings));
|
||||
} else {
|
||||
g_snprintf(result+offset_r, size-offset_r,
|
||||
"%." G_STRINGIFY(FLT_DIG) "g", fvalue_get_floating(&finfo->value));
|
||||
|
@ -5978,7 +5978,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
double d_value = fvalue_get_floating(&finfo->value);
|
||||
g_snprintf(result+offset_r, size-offset_r,
|
||||
"%." G_STRINGIFY(DBL_DIG) "g%s", d_value,
|
||||
unit_name_string_get_double(d_value, (unit_name_string*)hfinfo->strings));
|
||||
unit_name_string_get_double(d_value, (const unit_name_string*)hfinfo->strings));
|
||||
} else {
|
||||
g_snprintf(result+offset_r, size-offset_r,
|
||||
"%." G_STRINGIFY(DBL_DIG) "g", fvalue_get_floating(&finfo->value));
|
||||
|
@ -8224,7 +8224,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
|
|||
g_snprintf(label_str, ITEM_LABEL_LENGTH,
|
||||
"%s: %." G_STRINGIFY(FLT_DIG) "g%s",
|
||||
hfinfo->name, d_value,
|
||||
unit_name_string_get_double(d_value, (unit_name_string*)hfinfo->strings));
|
||||
unit_name_string_get_double(d_value, (const unit_name_string*)hfinfo->strings));
|
||||
} else {
|
||||
g_snprintf(label_str, ITEM_LABEL_LENGTH,
|
||||
"%s: %." G_STRINGIFY(FLT_DIG) "g",
|
||||
|
@ -8240,7 +8240,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
|
|||
g_snprintf(label_str, ITEM_LABEL_LENGTH,
|
||||
"%s: %." G_STRINGIFY(DBL_DIG) "g%s",
|
||||
hfinfo->name, d_value,
|
||||
unit_name_string_get_double(d_value, (unit_name_string*)hfinfo->strings));
|
||||
unit_name_string_get_double(d_value, (const unit_name_string*)hfinfo->strings));
|
||||
} else {
|
||||
g_snprintf(label_str, ITEM_LABEL_LENGTH,
|
||||
"%s: %." G_STRINGIFY(DBL_DIG) "g",
|
||||
|
@ -8468,7 +8468,7 @@ hf_try_val_to_str(guint32 value, const header_field_info *hfinfo)
|
|||
return try_val64_to_str(value, (const val64_string *) hfinfo->strings);
|
||||
|
||||
if (hfinfo->display & BASE_UNIT_STRING)
|
||||
return unit_name_string_get_value(value, (struct unit_name_string*) hfinfo->strings);
|
||||
return unit_name_string_get_value(value, (const struct unit_name_string*) hfinfo->strings);
|
||||
|
||||
return try_val_to_str(value, (const value_string *) hfinfo->strings);
|
||||
}
|
||||
|
@ -8483,7 +8483,7 @@ hf_try_val64_to_str(guint64 value, const header_field_info *hfinfo)
|
|||
return try_rval64_to_str(value, (const range_string *) hfinfo->strings);
|
||||
|
||||
if (hfinfo->display & BASE_UNIT_STRING)
|
||||
return unit_name_string_get_value64(value, (struct unit_name_string*) hfinfo->strings);
|
||||
return unit_name_string_get_value64(value, (const struct unit_name_string*) hfinfo->strings);
|
||||
|
||||
/* If this is reached somebody registered a 64-bit field with a 32-bit
|
||||
* value-string, which isn't right. */
|
||||
|
@ -9799,7 +9799,7 @@ proto_registrar_dump_values(void)
|
|||
if (hfinfo->display & BASE_RANGE_STRING) {
|
||||
range = (const range_string *)hfinfo->strings;
|
||||
} else if (hfinfo->display & BASE_EXT_STRING) {
|
||||
vals = VALUE_STRING_EXT_VS_P((value_string_ext *)hfinfo->strings);
|
||||
vals = VALUE_STRING_EXT_VS_P((const value_string_ext *)hfinfo->strings);
|
||||
} else if (hfinfo->display & BASE_VAL64_STRING) {
|
||||
vals64 = (const val64_string *)hfinfo->strings;
|
||||
} else if (hfinfo->display & BASE_UNIT_STRING) {
|
||||
|
@ -10547,7 +10547,7 @@ proto_item_add_bitmask_tree(proto_item *item, tvbuff_t *tvb, const int offset,
|
|||
|
||||
out = hfinfo_number_value_format(hf, buf, (guint32) tmpval);
|
||||
if (hf->display & BASE_UNIT_STRING) {
|
||||
proto_item_append_text(item, "%s: %s%s", hf->name, out, unit_name_string_get_value((guint32) tmpval, (unit_name_string*)hf->strings));
|
||||
proto_item_append_text(item, "%s: %s%s", hf->name, out, unit_name_string_get_value((guint32) tmpval, (const unit_name_string*)hf->strings));
|
||||
} else {
|
||||
proto_item_append_text(item, "%s: %s", hf->name, out);
|
||||
}
|
||||
|
@ -10590,7 +10590,7 @@ proto_item_add_bitmask_tree(proto_item *item, tvbuff_t *tvb, const int offset,
|
|||
|
||||
out = hfinfo_number_value_format(hf, buf, (gint32) integer32);
|
||||
if ((hf->strings) &&(!(hf->display & BASE_UNIT_STRING))) {
|
||||
proto_item_append_text(item, "%s: %s%s", hf->name, out, unit_name_string_get_value((guint32) tmpval, (unit_name_string*)hf->strings));
|
||||
proto_item_append_text(item, "%s: %s%s", hf->name, out, unit_name_string_get_value((guint32) tmpval, (const unit_name_string*)hf->strings));
|
||||
} else {
|
||||
proto_item_append_text(item, "%s: %s", hf->name, out);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <wsutil/str_util.h>
|
||||
#include "unit_strings.h"
|
||||
|
||||
char* unit_name_string_get_value(guint32 value, unit_name_string* units)
|
||||
const char* unit_name_string_get_value(guint32 value, const unit_name_string* units)
|
||||
{
|
||||
if (units->plural == NULL)
|
||||
return units->singular;
|
||||
|
@ -22,7 +22,7 @@ char* unit_name_string_get_value(guint32 value, unit_name_string* units)
|
|||
return plurality(value, units->singular, units->plural);
|
||||
}
|
||||
|
||||
char* unit_name_string_get_value64(guint64 value, unit_name_string* units)
|
||||
const char* unit_name_string_get_value64(guint64 value, const unit_name_string* units)
|
||||
{
|
||||
if (units->plural == NULL)
|
||||
return units->singular;
|
||||
|
@ -30,7 +30,7 @@ char* unit_name_string_get_value64(guint64 value, unit_name_string* units)
|
|||
return plurality(value, units->singular, units->plural);
|
||||
}
|
||||
|
||||
char* unit_name_string_get_double(double value, unit_name_string* units)
|
||||
const char* unit_name_string_get_double(double value, const unit_name_string* units)
|
||||
{
|
||||
if (units->plural == NULL)
|
||||
return units->singular;
|
||||
|
|
|
@ -27,9 +27,9 @@ typedef struct unit_name_string {
|
|||
char *plural; /* name to use for < 1 or > 1 units */
|
||||
} unit_name_string;
|
||||
|
||||
WS_DLL_PUBLIC char* unit_name_string_get_value(guint32 value, unit_name_string* units);
|
||||
WS_DLL_PUBLIC char* unit_name_string_get_value64(guint64 value, unit_name_string* units);
|
||||
WS_DLL_PUBLIC char* unit_name_string_get_double(double value, unit_name_string* units);
|
||||
WS_DLL_PUBLIC const char* unit_name_string_get_value(guint32 value, const unit_name_string* units);
|
||||
WS_DLL_PUBLIC const char* unit_name_string_get_value64(guint64 value, const unit_name_string* units);
|
||||
WS_DLL_PUBLIC const char* unit_name_string_get_double(double value, const unit_name_string* units);
|
||||
|
||||
/*
|
||||
* A default set of unit strings that dissectors can use for
|
||||
|
|
Loading…
Reference in New Issue