Re: [PATCH 4/4] v4l-utils: use 64-bit formats for time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 2, 2024 at 12:33 PM Rosen Penev <rosenp@xxxxxxxxx> wrote:
>
> musl since version 1.2.0 uses 64-bit time_t and suseconds_t on all
> platforms, even 32-bit. Cast to avoid warnings and potentially future
> proof for when glibc and others gain support.
>
> Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
ping
> ---
>  utils/cec-compliance/cec-compliance.cpp   |  2 +-
>  utils/cec-compliance/cec-test-adapter.cpp |  4 ++--
>  utils/cec-ctl/cec-ctl.cpp                 | 18 +++++++++---------
>  utils/cec-follower/cec-processing.cpp     |  2 +-
>  4 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp
> index 8075e1d6..bddd57cb 100644
> --- a/utils/cec-compliance/cec-compliance.cpp
> +++ b/utils/cec-compliance/cec-compliance.cpp
> @@ -279,7 +279,7 @@ static std::string ts2s(__u64 ts)
>         t = res.tv_sec;
>         s = ctime(&t);
>         s = s.substr(0, s.length() - 6);
> -       sprintf(buf, "%03lu", res.tv_usec / 1000);
> +       sprintf(buf, "%03llu", (__u64)res.tv_usec / 1000);
>         return s + "." + buf;
>  }
>
> diff --git a/utils/cec-compliance/cec-test-adapter.cpp b/utils/cec-compliance/cec-test-adapter.cpp
> index 08c856af..f96baaf3 100644
> --- a/utils/cec-compliance/cec-test-adapter.cpp
> +++ b/utils/cec-compliance/cec-test-adapter.cpp
> @@ -1276,9 +1276,9 @@ static int testLostMsgs(struct node *node)
>                         printf("\t\tReceived messages: %d of which %d were CEC_MSG_CEC_VERSION\n",
>                                pending_rx_msgs, pending_rx_cec_version_msgs);
>                 if (pending_quick_msgs < pending_msgs)
> -                       printf("\t\tReceived %d messages immediately, and %d over %ld seconds\n",
> +                       printf("\t\tReceived %d messages immediately, and %d over %llu seconds\n",
>                                pending_quick_msgs, pending_msgs - pending_quick_msgs,
> -                              time(nullptr) - start);
> +                              (__u64)time(nullptr) - start);
>         }
>         print_sfts(sft[1][1], "SFTs for repeating messages (>= 7)");
>         print_sfts(sft[1][0], "SFTs for repeating remote messages (>= 7)");
> diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
> index 8848a49d..f7ba7409 100644
> --- a/utils/cec-ctl/cec-ctl.cpp
> +++ b/utils/cec-ctl/cec-ctl.cpp
> @@ -414,7 +414,7 @@ std::string ts2s(__u64 ts)
>                 strftime(buf, sizeof(buf), "%a %b %e %T.000000", &tm);
>         }
>         secs = last_secs + t - last_t;
> -       sprintf(buf + 14, "%02u:%02u.%06lu", secs / 60, secs % 60, res.tv_usec);
> +       sprintf(buf + 14, "%02u:%02u.%06llu", secs / 60, secs % 60, (__u64)res.tv_usec);
>         return buf;
>  }
>
> @@ -942,10 +942,10 @@ static void monitor(const struct node &node, __u32 monitor_time, const char *sto
>                 }
>                 fprintf(fstore, "# cec-ctl --store-pin\n");
>                 fprintf(fstore, "# version %d\n", CEC_CTL_VERSION);
> -               fprintf(fstore, "# start_monotonic %lu.%09lu\n",
> -                       start_monotonic.tv_sec, start_monotonic.tv_nsec);
> -               fprintf(fstore, "# start_timeofday %lu.%06lu\n",
> -                       start_timeofday.tv_sec, start_timeofday.tv_usec);
> +               fprintf(fstore, "# start_monotonic %llu.%09llu\n",
> +                       (__u64)start_monotonic.tv_sec, (__u64)start_monotonic.tv_nsec);
> +               fprintf(fstore, "# start_timeofday %llu.%06llu\n",
> +                       (__u64)start_timeofday.tv_sec, (__u64)start_timeofday.tv_usec);
>                 fprintf(fstore, "# log_addr_mask 0x%04x\n", node.log_addr_mask);
>                 fprintf(fstore, "# phys_addr %x.%x.%x.%x\n",
>                         cec_phys_addr_exp(node.phys_addr));
> @@ -984,10 +984,10 @@ static void monitor(const struct node &node, __u32 monitor_time, const char *sto
>                          */
>                         clock_gettime(CLOCK_MONOTONIC, &start_monotonic);
>                         gettimeofday(&start_timeofday, nullptr);
> -                       fprintf(fstore, "# start_monotonic %lu.%09lu\n",
> -                               start_monotonic.tv_sec, start_monotonic.tv_nsec);
> -                       fprintf(fstore, "# start_timeofday %lu.%06lu\n",
> -                               start_timeofday.tv_sec, start_timeofday.tv_usec);
> +                       fprintf(fstore, "# start_monotonic %llu.%09llu\n",
> +                               (__u64)start_monotonic.tv_sec, (__u64)start_monotonic.tv_nsec);
> +                       fprintf(fstore, "# start_timeofday %llu.%06llu\n",
> +                               (__u64)start_timeofday.tv_sec, (__u64)start_timeofday.tv_usec);
>                         fflush(fstore);
>                         start_minute = now;
>                 }
> diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp
> index 14ee211b..cd20df59 100644
> --- a/utils/cec-follower/cec-processing.cpp
> +++ b/utils/cec-follower/cec-processing.cpp
> @@ -72,7 +72,7 @@ static std::string ts2s(__u64 ts, bool wallclock)
>         t = res.tv_sec;
>         s = ctime(&t);
>         s = s.substr(0, s.length() - 6);
> -       sprintf(buf, "%03lu", res.tv_usec / 1000);
> +       sprintf(buf, "%03llu", (__u64)res.tv_usec / 1000);
>         return s + "." + buf;
>  }
>
> --
> 2.45.2
>





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux