On Fri, 6 Nov 2020 11:58:04 GMT, Coleen Phillimore <[email protected]> wrote:
>> The concern is when it is less than 100ms.
>
> unsigned millisecs[] = { 2, 20, 200, 1000 };
> get_time_stamp(millisecs[i], buf, sizeof(buf));
>
> gets:
>
> timestamp 06.11.2020 06:56:08.002 EST
> timestamp 06.11.2020 06:56:08.020 EST
> timestamp 06.11.2020 06:56:08.200 EST
> timestamp 06.11.2020 06:56:08.1000 EST
>
> with
>
> char tmp[10 + 1];
> snprintf(tmp, sizeof(tmp), "%.3d", millisecs);
> snprintf(tbuf, ltbuf, "%s.%s %s", timestamp_date_time, tmp,
> timestamp_timezone);
>
> Is this what you want?
I think you need .3 in both places, otherwise I expect the warning will still
be there? (We don't need to worry about values of millisecs larger than 999):
char tmp[11 + 1];
snprintf(tmp, sizeof(tmp), "%.3d", millisecs);
snprintf(tbuf, ltbuf, "%s.%.3s %s", timestamp_date_time, tmp,
timestamp_timezone);
-------------
PR: https://git.openjdk.java.net/jdk/pull/1067