Skip to content

Commit

Permalink
dfilter: Fix printing of nanosecond fractions of time.
Browse files Browse the repository at this point in the history
The code is incorrectly also omitting zeros that are significant
from the representation of fractional values of absolute time
in display filters (with FTREPR_DFILTER).

Instead of fixing the representation just remove the buggy code and
include all 9 digits of fractional seconds, including trailing zeros
to the right of the decimal point, which in this case can be inferred
to indicate the precision (to the nanosecond).
  • Loading branch information
randstr committed Sep 6, 2023
1 parent ba7cf62 commit f58b451
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions epan/ftypes/ftype-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ abs_time_to_ftrepr_dfilter(wmem_allocator_t *scope,
{
struct tm *tm;
char datetime_format[128];
int nsecs;
char nsecs_buf[32];

if (use_utc) {
Expand All @@ -368,11 +367,7 @@ abs_time_to_ftrepr_dfilter(wmem_allocator_t *scope,
if (nstime->nsecs == 0)
return wmem_strdup_printf(scope, datetime_format, "");

nsecs = nstime->nsecs;
while (nsecs > 0 && (nsecs % 10) == 0) {
nsecs /= 10;
}
snprintf(nsecs_buf, sizeof(nsecs_buf), ".%d", nsecs);
snprintf(nsecs_buf, sizeof(nsecs_buf), ".%09d", nstime->nsecs);

return wmem_strdup_printf(scope, datetime_format, nsecs_buf);
}
Expand Down

0 comments on commit f58b451

Please sign in to comment.