From fb368c32be26bd0a424d5cbcf36b14d45c562287 Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic <janusz.dziedzic@iopsys.eu> Date: Fri, 13 May 2022 12:29:33 +0200 Subject: [PATCH] opclass use timestamp_* util functions Signed-off-by: Janusz Dziedzic <janusz.dziedzic@iopsys.eu> --- src/cntlr.c | 5 +---- src/cntlr_ubus.c | 2 +- src/utils/opclass.c | 2 +- src/utils/opclass.h | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cntlr.c b/src/cntlr.c index 6f1a39ec..46ab1cf2 100644 --- a/src/cntlr.c +++ b/src/cntlr.c @@ -1200,13 +1200,10 @@ void cntlr_radio_cur_opclass_dump(struct netif_radio *radio) static bool cntlr_radio_opclass_expired(struct netif_radio *radio) { - time_t age; - if (!radio->opclass.entry_num) return true; - age = time(NULL) - radio->opclass.entry_time; - if (((unsigned int) age) > 120) + if (timestamp_expired(&radio->opclass.entry_time, 120000)) return true; return false; diff --git a/src/cntlr_ubus.c b/src/cntlr_ubus.c index 06fefc97..313543c8 100644 --- a/src/cntlr_ubus.c +++ b/src/cntlr_ubus.c @@ -438,7 +438,7 @@ static void cntlr_status_add_opclass(struct blob_buf *bb, struct opclass *opclas /* Add age */ snprintf(age, sizeof(age), "%s_age", name); - blobmsg_add_u32(bb, age, (uint32_t) (time(NULL) - opclass->entry_time)); + blobmsg_add_u32(bb, age, timestamp_elapsed_sec(&opclass->entry_time)); a = blobmsg_open_array(bb, name); for (j = 0; j < opclass->entry_num; j++) { diff --git a/src/utils/opclass.c b/src/utils/opclass.c index eaf4018b..913fec61 100644 --- a/src/utils/opclass.c +++ b/src/utils/opclass.c @@ -34,7 +34,7 @@ struct opclass_entry *opclass_new_entry(struct opclass *opclass) entry = &opclass->entry[opclass->entry_num]; opclass->entry_num++; - opclass->entry_time = time(NULL); + timestamp_update(&opclass->entry_time); return entry; } diff --git a/src/utils/opclass.h b/src/utils/opclass.h index 88bb0c43..35b0586e 100644 --- a/src/utils/opclass.h +++ b/src/utils/opclass.h @@ -28,7 +28,7 @@ struct opclass_entry { }; struct opclass { - time_t entry_time; + struct timespec entry_time; int entry_num; struct opclass_entry entry[64]; -- GitLab