Skip to content

Commit

Permalink
output/csv: use intermediate time_t var, silence compiler warning
Browse files Browse the repository at this point in the history
There are platforms where timeval and time_t disagree on the width of
the data type of the field which holds seconds. Passing a pointer to an
unexpected type results in warnings (and probably unreliable execution).

Assign the value which is gotten from a timeval to an intermediate
time_t variable, so that the ctime() invocation becomes portable.
  • Loading branch information
gsigh committed Jan 3, 2024
1 parent 0fd3ed0 commit b503d24
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/output/csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ static GString *gen_header(const struct sr_output *o,
/* Some metadata */
if (ctx->header && !ctx->did_header) {
/* save_gnuplot knows how many lines we print. */
time_t secs;
secs = hdr->starttime.tv_sec;
g_string_append_printf(header,
"%s CSV generated by %s %s\n%s from %s on %s",
ctx->comment, PACKAGE_NAME,
sr_package_version_string_get(), ctx->comment,
ctx->title, ctime(&hdr->starttime.tv_sec));
ctx->title, ctime(&secs));

/* Columns / channels */
channels = o->sdi ? o->sdi->channels : NULL;
Expand Down

0 comments on commit b503d24

Please sign in to comment.