Do not print success notices if clockadj operation fails using return values provided by the clockadj helpers.
Signed-off-by: Rahul Rameshbabu <rrameshb...@nvidia.com> --- Notes: Changes: v1->v2: - Accounted for conditional formatting changes suggested by Erez. - Added pre-emptive return on error since clockadj_step prints an error message as suggested by Erez. phc_ctl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/phc_ctl.c b/phc_ctl.c index 53b26e1..416c33f 100644 --- a/phc_ctl.c +++ b/phc_ctl.c @@ -232,9 +232,10 @@ static int do_adj(clockid_t clkid, int cmdc, char *cmdv[]) nsecs = (int64_t)(NSEC_PER_SEC * time_arg); clockadj_init(clkid); - clockadj_step(clkid, nsecs); - - pr_notice("adjusted clock by %lf seconds", time_arg); + if (clockadj_step(clkid, nsecs) == 0) + pr_notice("adjusted clock by %lf seconds", time_arg); + else + return -2; /* adjustment always consumes one argument */ return 1; @@ -271,8 +272,8 @@ static int do_freq(clockid_t clkid, int cmdc, char *cmdv[]) return -2; } - clockadj_set_freq(clkid, ppb); - pr_notice("adjusted clock frequency offset to %lfppb", ppb); + if (clockadj_set_freq(clkid, ppb) == 0) + pr_notice("adjusted clock frequency offset to %lfppb", ppb); /* consumed one argument to determine the frequency adjustment value */ return 1; @@ -308,10 +309,9 @@ static int do_phase(clockid_t clkid, int cmdc, char *cmdv[]) nsecs = (long)(NSEC_PER_SEC * offset_arg); clockadj_init(clkid); - clockadj_set_phase(clkid, nsecs); - - pr_notice("offset of %lf seconds provided to PHC phase control keyword", - offset_arg); + if (clockadj_set_phase(clkid, nsecs) == 0) + pr_notice("offset of %lf seconds provided to PHC phase control keyword", + offset_arg); /* phase offset always consumes one argument */ return 1; -- 2.40.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel