From: Sascha Hauer <sha@pengutronix.de> To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de> Cc: barebox@lists.infradead.org Subject: Re: [PATCH] scripts/kwboot: Fix normalizing timeval Date: Tue, 7 Dec 2021 10:07:04 +0100 Message-ID: <20211207090704.GG28260@pengutronix.de> (raw) In-Reply-To: <20211130160308.316863-1-u.kleine-koenig@pengutronix.de> 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@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@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 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2021-12-07 9:14 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-30 16:03 Uwe Kleine-König 2021-12-07 9:07 ` Sascha Hauer [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211207090704.GG28260@pengutronix.de \ --to=sha@pengutronix.de \ --cc=barebox@lists.infradead.org \ --cc=u.kleine-koenig@pengutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
mail archive of the barebox mailing list This inbox may be cloned and mirrored by anyone: git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \ barebox@lists.infradead.org barebox@lists.infradead.org public-inbox-index barebox Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git