Skip to content

Commit b503d24

Browse files
committed
output/csv: use intermediate time_t var, silence compiler warning
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.
1 parent 0fd3ed0 commit b503d24

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/output/csv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,13 @@ static GString *gen_header(const struct sr_output *o,
252252
/* Some metadata */
253253
if (ctx->header && !ctx->did_header) {
254254
/* save_gnuplot knows how many lines we print. */
255+
time_t secs;
256+
secs = hdr->starttime.tv_sec;
255257
g_string_append_printf(header,
256258
"%s CSV generated by %s %s\n%s from %s on %s",
257259
ctx->comment, PACKAGE_NAME,
258260
sr_package_version_string_get(), ctx->comment,
259-
ctx->title, ctime(&hdr->starttime.tv_sec));
261+
ctx->title, ctime(&secs));
260262

261263
/* Columns / channels */
262264
channels = o->sdi ? o->sdi->channels : NULL;

0 commit comments

Comments
 (0)