Bugs
Search the entire project
This project's trackers
This project's tasks
Project
People
Skill
Advanced search
Log In
|
New Account
Home
My Page
Projects
Code Snippets
Project Openings
Network UPS Tools
Summary
Activity
Tracker
Lists
Tasks
SCM
Website - Dev
Buildbot
GitHub
[#313634] Use difftime for time comparison
View Trackers
|
Bugs
|
Download .csv
|
Monitor
Date:
2012-05-15 12:34
Priority:
3
State:
Closed
Submitted by:
Arnaud Quette (
aquette
)
Assigned to:
Vaclav Krpec (vencik-guest)
Category:
None
Group:
None
Resolution:
None
Summary:
Use difftime for time comparison
Detailed description
prefer to use difftime() for time comparison.
Missing implementations:
- mge-utalk
- snmp-ups
- usbhid-ups
- maybe some others...
Followup
Message
Date: 2013-02-15 23:11
Sender:
Arnaud Quette
Now handled on GitHub:
https://github.com/networkupstools/nut/issues/10
Date: 2012-09-26 08:27
Sender:
Vaclav Krpec
As for the clock_[gs]ettime, these will require wrappers for portability reasons.
If we want to use them (where possible, e.g. on Linux), I suggest to create our own opaque timer type + appropriate get/set/cmp/inc/dec etc iface that can be implemented either by the monotonic clock (if available) or simply by time_t (otherwise).
Then, usage of this type & iface should be wide-spread throughout the code, replacing time_t.
Shall I do it in scope of this bugfix? I'd recommend to create a feature req. for such a change (not a bug), however, I can do it, instantly...
Date: 2012-09-26 08:01
Sender:
Vaclav Krpec
On second thoughts, that shouldn't be real problem; however, at least it will be unified...
Date: 2012-09-26 06:58
Sender:
Vaclav Krpec
I've found at least 2 occurrences of the following practice as well (generalised & compacted):
nextpoll = now + interval;
/* ... */
if (difftime(nextpoll, now) < 0.0) /* or if (nextpoll < now) etc */
This is the same problem (for non numeric implementations of time_t).
I'm fixing it, too.
Date: 2012-09-24 12:41
Sender:
Charles Lepple
See also the patches for this bug, which tries to replace some instances of difftime() with a version that considers clock rollback:
https://alioth.debian.org/tracker/index.php?func=detail&aid=313714&group_id=30602&atid=411544
https://github.com/baruch/nut/commits/master/
Attached Files:
Changes:
Field
Old Value
Date
By
status_id
Open
2013-02-15 23:11
aquette
close_date
None
2013-02-15 23:11
aquette
assigned_to
none
2012-09-24 12:28
aquette
Show source