diff options
author | João Valverde <j@v6e.pt> | 2021-12-26 16:53:23 +0000 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-12-27 22:31:31 +0000 |
commit | a566076839b308cbad7822745f39b36e64b5e3e2 (patch) | |
tree | 61b7ed425d27adf2fa24197015c06c984b149600 /epan/to_str.c | |
parent | 0258ef3a041381f73dcdf447e6c857b2028019fb (diff) |
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.
Diffstat (limited to 'epan/to_str.c')
-rw-r--r-- | epan/to_str.c | 15 |
1 files changed, 13 insertions, 2 deletions
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"); |