If the pmc pointer is not set, then there is no need to read the time only to later discard the result. This patch simplifies the flow by returning early if there is no work to be done.
Signed-off-by: Richard Cochran <richardcoch...@gmail.com> --- pmc_agent.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pmc_agent.c b/pmc_agent.c index 24587b4..47562bc 100644 --- a/pmc_agent.c +++ b/pmc_agent.c @@ -342,14 +342,16 @@ int update_pmc_node(struct pmc_agent *node) struct timespec tp; uint64_t ts; + if (!node->pmc) { + return 0; + } if (clock_gettime(CLOCK_MONOTONIC, &tp)) { pr_err("failed to read clock: %m"); return -1; } ts = tp.tv_sec * NS_PER_SEC + tp.tv_nsec; - if (node->pmc && - !(ts > node->pmc_last_update && + if (!(ts > node->pmc_last_update && ts - node->pmc_last_update < PMC_UPDATE_INTERVAL)) { if (node->subscription_active) { renew_subscription(node, 0); -- 2.20.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel