From a566076839b308cbad7822745f39b36e64b5e3e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Sun, 26 Dec 2021 16:53:23 +0000 Subject: epan: Move time display types to field_display_e This makes it easier to understand the code, avoids conflicts and ugly and unnecessary casts. The field display enum has evolved over time from integer types to a type generic parameter. --- epan/to_str.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'epan/to_str.c') diff --git a/epan/to_str.c b/epan/to_str.c index 9de2e0a53b..9c98bf21c0 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -94,13 +94,14 @@ get_zonename(struct tm *tmp) } gchar * -abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, const absolute_time_display_e fmt, +abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, field_display_e fmt, gboolean show_zone) { struct tm *tmp = NULL; const char *zonename = "???"; gchar *buf = NULL; + ws_assert(FIELD_DISPLAY_IS_ABSOLUTE_TIME(fmt)); switch (fmt) { @@ -117,6 +118,8 @@ abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, const absolut zonename = get_zonename(tmp); } break; + default: + ws_assert_not_reached(); } if (tmp) { switch (fmt) { @@ -195,6 +198,8 @@ abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, const absolut (long)abs_time->nsecs); } break; + default: + ws_assert_not_reached(); } } else buf = wmem_strdup(scope, "Not representable"); @@ -202,13 +207,15 @@ abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, const absolut } gchar * -abs_time_secs_to_str(wmem_allocator_t *scope, const time_t abs_time, const absolute_time_display_e fmt, +abs_time_secs_to_str(wmem_allocator_t *scope, const time_t abs_time, field_display_e fmt, gboolean show_zone) { struct tm *tmp = NULL; const char *zonename = "???"; gchar *buf = NULL; + ws_assert(FIELD_DISPLAY_IS_ABSOLUTE_TIME(fmt)); + switch (fmt) { case ABSOLUTE_TIME_UTC: @@ -224,6 +231,8 @@ abs_time_secs_to_str(wmem_allocator_t *scope, const time_t abs_time, const absol zonename = get_zonename(tmp); } break; + default: + ws_assert_not_reached(); } if (tmp) { switch (fmt) { @@ -278,6 +287,8 @@ abs_time_secs_to_str(wmem_allocator_t *scope, const time_t abs_time, const absol tmp->tm_sec); } break; + default: + ws_assert_not_reached(); } } else buf = wmem_strdup(scope, "Not representable"); -- cgit v1.2.3