Re: [LTP] [PATCH v2] rtc02: loosen the compare precision with few seconds

Li Wang
2022-05-08T04:19:57Z

[-- Attachment #1.1: Type: text/plain, Size: 718 bytes --]

On Sun, May 8, 2022 at 11:06 AM Li Wang <liwang@redhat.com> wrote:

> + if (!(set_tm->tm_sec == read_tm->tm_sec)
> + || !(set_tm->tm_min == read_tm->tm_min)
> + || !(set_tm->tm_hour == read_tm->tm_hour)) {
>

nit: I should use 'A != B' directly but not '!(A==B)' in the expression.
That looks strange anyway.

> +
> + seconds1 = (set_tm->tm_hour * 3600) + (set_tm->tm_min *
> 60) + set_tm->tm_sec;
> + seconds2 = (read_tm->tm_hour * 3600) + (read_tm->tm_min *
> 60) + read_tm->tm_sec;
> +
> + delta = seconds2 - seconds1;
> +
> + if (delta < 0 || delta > 3)
>

Better to print seconds value if fails.

--
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 1702 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]