]> sigrok.org Git - libsigrok.git/commitdiff
output/csv: use intermediate time_t var, silence compiler warning master github/master
authorGerhard Sittig <redacted>
Mon, 1 Jan 2024 13:37:50 +0000 (14:37 +0100)
committerGerhard Sittig <redacted>
Wed, 3 Jan 2024 19:21:36 +0000 (20:21 +0100)
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.

src/output/csv.c

index 848595f9d3096b9570fcd0e5505e2d1026ea1250..c4801ef7f984bca96b432fda2eb37c55fd9da730 100644 (file)
@@ -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;