[PATCH] scripts/kwboot: Fix normalizing timeval
Sascha Hauer
sha at pengutronix.de
Tue Dec 7 01:07:04 PST 2021
On Tue, Nov 30, 2021 at 05:03:08PM +0100, Uwe Kleine-König wrote:
> If tv.tv_usec is 1000000 the structure needs normalizing, too. So the
> right check would be:
>
> if (tv.tv_usec >= 1000000) {
> ...
>
> But as normalizing doesn't destroy anything even for smaller values,
> just do it unconditionally to simplify a bit.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> ---
> scripts/kwboot.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/scripts/kwboot.c b/scripts/kwboot.c
> index 60e8a69d187d..1cbb456935f2 100644
> --- a/scripts/kwboot.c
> +++ b/scripts/kwboot.c
> @@ -147,12 +147,11 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo)
> FD_ZERO(&rfds);
> FD_SET(fd, &rfds);
>
> - tv.tv_sec = 0;
> tv.tv_usec = timeo * 1000;
> - if (tv.tv_usec > 1000000) {
> - tv.tv_sec += tv.tv_usec / 1000000;
> - tv.tv_usec %= 1000000;
> - }
> +
> + /* normalize timeval */
> + tv.tv_sec = tv.tv_usec / 1000000;
> + tv.tv_usec %= 1000000;
>
> do {
> nfds = select(fd + 1, &rfds, NULL, NULL, &tv);
>
> base-commit: f2dd8896846757829fb3033f41b89be3fc037d78
> --
> 2.30.2
>
>
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list