lkml.org 
[lkml]   [2014]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 1/2] mISDN: Use time_before()
Hello.

On 05/21/2014 11:10 PM, Manuel Schölling wrote:

> To be future-proof and for better readability the time comparisons are modified
> to use time_before() instead of plain, error-prone math.

> Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
> ---
> drivers/isdn/mISDN/l1oip_core.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)

> diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
> index 2c0d2c2..1c2bc36 100644
> --- a/drivers/isdn/mISDN/l1oip_core.c
> +++ b/drivers/isdn/mISDN/l1oip_core.c
> @@ -287,7 +287,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
> p = frame;
>
> /* restart timer */
> - if ((int)(hc->keep_tl.expires-jiffies) < 5 * HZ) {
> + if (time_before(hc->keep_tl.expires - 5 * HZ, jiffies)) {

Wouldn't it be clearer this way:

if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ)) {

> del_timer(&hc->keep_tl);
> hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
> add_timer(&hc->keep_tl);
> @@ -621,7 +621,8 @@ multiframe:
> goto multiframe;
>
> /* restart timer */
> - if ((int)(hc->timeout_tl.expires-jiffies) < 5 * HZ || !hc->timeout_on) {
> + if (time_before(hc->timeout_tl.expires - 5 * HZ, jiffies)
> + || !hc->timeout_on) {

Please leave || on the previous line.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2014-05-21 22:01    [W:0.044 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site