From: Urs Thuermann <urs@isnogud.escape.de>
To: linux-kernel@vger.kernel.org
Subject: Re: [BUG] settimeofday(2) succeeds for microsecond value more than USEC_PER_SEC and for negative value
Date: 02 May 2003 20:06:13 +0200 [thread overview]
Message-ID: <m265otw7e2.fsf@isnogud.escape.de> (raw)
In-Reply-To: <3E973546.70809@mvista.com>; from george anzinger on Fri, 11 Apr 2003 14:36:06 -0700
george anzinger <george@mvista.com> writes:
> Uh, sure. This is the test I prefer:
>
> if( (unsigned long)tv->usec > USEC_PER_SEC)
> return EINVAL;
>
> Note that the unsigned picks up the negative value as well as the >
> (and it does it in only one machine code test/jmp :)
No, don't do the compilers job. Just write
if (tv->usec < 0 || tv->usec >= USEC_PER_SEC) { ... }
This is easier to read, portable, and generates the same machine code
as your C code, at least in all gcc versions since gcc-2.7.2.3 (I
don't have older gcc versions here on my machine to test).
urs
next prev parent reply other threads:[~2003-05-02 17:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-11 13:07 [BUG] settimeofday(2) succeeds for microsecond value more than USEC_PER_SEC and for negative value Aniruddha M Marathe
2003-04-11 21:36 ` george anzinger
2003-05-02 18:06 ` Urs Thuermann [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-04-12 10:43 Aniruddha M Marathe
2003-04-12 19:25 ` george anzinger
2003-04-11 5:12 Aniruddha M Marathe
2003-04-11 6:26 ` george anzinger
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=m265otw7e2.fsf@isnogud.escape.de \
--to=urs@isnogud.escape.de \
--cc=linux-kernel@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).