From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lib/tst_timer_test.c: fix unsigned int overflow on RHEL5.11GA
Date: Thu, 20 Jul 2017 17:25:30 +0800 [thread overview]
Message-ID: <5970770A.4000703@cn.fujitsu.com> (raw)
In-Reply-To: <20170720091359.GA27245@rei>
On 2017/07/20 17:13, Cyril Hrubis wrote:
> Hi!
>> It sounds better, but this change leads that samples[0] could not be
>> checked if the whole samples array
>> is less than usec.
>>
>> Could we fix this issue as below:
>> ------------------------------------------------------------------------------------------------------------------------
>> - for (i = nsamples - 1; samples[i]< usec; i--);
>> + for (i = nsamples - 1; samples[i]< usec&& i> 0; i--);
>>
>> if (i< nsamples - 1) {
>> - tst_res(TFAIL, "%s woken up early %u times range: [%lli,%lli]",
>> - scall, nsamples - 1 - i,
>> - samples[i+1], samples[nsamples-1]);
>> + if (i == 0&& samples[i]< usec) {
>> + tst_res(TFAIL, "%s woken up early %u times range: [%lli,%lli]",
>> + scall, nsamples - i, samples[i],
>> + samples[nsamples-1]);
>> + } else {
>> + tst_res(TFAIL, "%s woken up early %u times range: [%lli,%lli]",
>> + scall, nsamples - 1 - i, samples[i+1],
>> + samples[nsamples-1]);
>> + }
>> ------------------------------------------------------------------------------------------------------------------------
> That is still unnecessarily complex. I do not care that much about this
> corner case, but if we want to fix it correctly we can simply change the
> i to be signed integer and check for i> -1 in the loop and everything
> would work fine.
Hi Cyril,
Thanks for your explanation. I will send v2 patch as you said.
Thanks,
Xiao Yang
next prev parent reply other threads:[~2017-07-20 9:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-17 6:53 [LTP] [PATCH] lib/tst_timer_test.c: fix unsigned int overflow on RHEL5.11GA Xiao Yang
2017-07-19 12:15 ` Cyril Hrubis
2017-07-20 2:21 ` Xiao Yang
2017-07-20 9:13 ` Cyril Hrubis
2017-07-20 9:25 ` Xiao Yang [this message]
2017-07-20 9:38 ` [LTP] [PATCH v2] " Xiao Yang
2017-07-20 11:29 ` Cyril Hrubis
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=5970770A.4000703@cn.fujitsu.com \
--to=yangx.jy@cn.fujitsu.com \
--cc=ltp@lists.linux.it \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.