AW: AW: [PATCH 4/4] kern_ntptime: sys_ntp_adjtime() does not return error when modes is 0 or MOD_TAI

Gabriel.Moyano at dlr.de Gabriel.Moyano at dlr.de
Tue Feb 8 07:13:44 UTC 2022


> >> What is the reason for this patch?
> >>
> > This change is something I would like to have a second opinion. So, thanks for the question.
> >
> > Originally at the end of sys_ntp_adjtime(), if the function copyout() doesn't return an error, the value returned by
> ntp_is_time_error(), which variable name is retval, is saved in td->td_retval[0]. Chris modified this, being retval saved in the variable
> error, which is the one returned by sys_ntp_adjtime().
> 
> In libbsd, copyout() is just a memcpy() which returns 0.
> 
> >
> > Under some situations, ntp_adjtime() is called with modes = 0 just for retrieving some values (for example
> herehttps://github.com/ptpd/ptpd/blob/master/src/dep/sys.c#L2036, please notice that here adjtimex() is ntp_adjtime()). In those
> cases, returning retval may not be meaningful. Other similar situation happens when mode is MOD_TAI
> (https://github.com/ptpd/ptpd/blob/master/src/dep/sys.c#L2070).
> >
> > This is more or less the reason. If there is better way to solve this, is welcome.
> 
> I don't think the changes make sense. The td->td_retval[0] is the return value of the system call if it is successful.  The "error" indicates
> if the system call was successful (== 0), otherwise it returns -1 with errno set to "error".
> 
So, do you also propose to remove the line "error = retval;" ? I think it is better keeping the return value meaning of sys_ntp_adjtime(), i.e. just returning 0 (successful) or -1 (in case of error)


More information about the devel mailing list