On Friday, December 02, 2011 22:37:31 Martin Hundebøll wrote:
Both translation tables and network coding use timeouts to do house keeping, so we might as well share the function used to compare a timestamp+timeout with current time.
Signed-off-by: Martin Hundebøll martin@hundeboll.net
main.c | 5 +++++ main.h | 1 + translation-table.c | 8 -------- 3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/main.c b/main.c index 71b56cf..0930bb4 100644 --- a/main.c +++ b/main.c @@ -172,6 +172,11 @@ int is_my_mac(const uint8_t *addr) return 0; }
+bool is_out_of_time(unsigned long timestamp, unsigned long timeout) +{
return time_is_before_jiffies(timestamp +
msecs_to_jiffies(timeout)); +}
Since it is a simple one-liner you could make it a define or at least static inline (in main.h).
How about a more descriptive name like "reached_timeout()" or "has_timed_out()" ? We could use it in other parts of the code too.
You might also want to add a few words about the fact that you did not only move the function but also changed time_after() to time_is_before_jiffies() at the same time.
Regards, Marek