#1894 closed defect (fixed)

missing a tick in _Timespec_To_ticks

Reported by: Jie Liu Owned by: Joel Sherrill
Priority: normal Milestone: 4.11
Component: score Version: 4.10
Severity: normal Keywords:
Cc: sebastian.huber@…, gedare@… Blocked By:
Blocking:

Description

It appears to miss a tick when use _Timespec_To_ticks.

Attachments (2)

1894.patch (494 bytes) - added by Jie Liu on Aug 9, 2011 at 12:23:24 PM.
We should add one tick if not divisible
pr1894.diff (3.5 KB) - added by Joel Sherrill on Aug 21, 2011 at 6:11:08 PM.
Cover over time conversion helpers.

Download all attachments as: .zip

Change History (7)

Changed on Aug 9, 2011 at 12:23:24 PM by Jie Liu

Attachment: 1894.patch added

We should add one tick if not divisible

comment:1 Changed on Aug 9, 2011 at 3:04:18 PM by Gedare Bloom

Cc: giddyup44@… added

Changed on Aug 21, 2011 at 6:11:08 PM by Joel Sherrill

Attachment: pr1894.diff added

Cover over time conversion helpers.

comment:2 Changed on Aug 21, 2011 at 6:11:08 PM by Joel Sherrill

attachments.isobsolete: 01

comment:3 Changed on Aug 22, 2011 at 2:37:10 PM by Sebastian Huber

Cc: Sebastian Huber added

comment:4 Changed on Sep 1, 2011 at 5:27:41 PM by Joel Sherrill

Resolution: fixed
Status: newclosed

comment:5 Changed on Sep 2, 2011 at 3:55:38 PM by Gedare Bloom

Replying to comment:20:

The (a + b - 1) / b may lead to an integer overflow, so we should avoid this
here. There are some integer conversion warnings in timespectoticks.c:

timespectoticks.c: In function '_Timespec_To_ticks':
timespectoticks.c:48:31: warning: conversion to 'long unsigned int' from
'time_t' may change the sign of the result [-Wsign-conversion]
timespectoticks.c:50:31: warning: conversion to 'long unsigned int' from 'long
int' may change the sign of the result [-Wsign-conversion]
timespectoticks.c:52:13: warning: conversion to 'long unsigned int' from 'long
int' may change the sign of the result [-Wsign-conversion]

Is the overflow possible in timespectotick? I believe tv_nsec is bounded somehow (less than 1000000000 or so)? And nsec per tick can be reasonably bounded. If so we can do some math to convince ourselves. For the general utility functions to convert ms to ticks for example the overflow is a problem I suppose.

Note: See TracTickets for help on using tickets.