The branch, master has been updated via c7488bf9e39 lib: util: Make nt_time_to_full_timespec() call nt_time_to_unix_timespec_raw() for the conversion. via 545442ec0ca lib: util: Make nt_time_to_unix_timespec() call nt_time_to_unix_timespec_raw() for the conversion. from cebf26d0624 s3:modules: Fix possible dereference of NULL for fio
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit c7488bf9e39ee4560061bf90a42c60c9590f7ff2 Author: Jeremy Allison <j...@samba.org> Date: Fri Jan 7 11:27:16 2022 -0800 lib: util: Make nt_time_to_full_timespec() call nt_time_to_unix_timespec_raw() for the conversion. Cleanup to eliminate duplicate code. The high check is now done against ret.tv_sec, not 'd', as after calling nt_time_to_unix_timespec_raw() this is identical to the previous intermediate 'd' variable. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Tue Jan 11 01:36:51 UTC 2022 on sn-devel-184 commit 545442ec0cab9ed06b1fa2be125ca36296597048 Author: Jeremy Allison <j...@samba.org> Date: Fri Jan 7 11:22:03 2022 -0800 lib: util: Make nt_time_to_unix_timespec() call nt_time_to_unix_timespec_raw() for the conversion. Cleanup to eliminate duplicate code. The low/high checks are now done against ret.tv_sec, not 'd', as after calling nt_time_to_unix_timespec_raw() this is identical to the previous intermediate 'd' variable. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> ----------------------------------------------------------------------- Summary of changes: lib/util/time.c | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/util/time.c b/lib/util/time.c index 5839e80a15b..f1d6b566618 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -899,7 +899,6 @@ struct timespec nt_time_to_unix_timespec_raw( struct timespec nt_time_to_unix_timespec(NTTIME nt) { - int64_t d; struct timespec ret; if (nt == 0 || nt == (int64_t)-1) { @@ -908,35 +907,19 @@ struct timespec nt_time_to_unix_timespec(NTTIME nt) return ret; } - d = (int64_t)nt; - /* d is now in 100ns units, since jan 1st 1601". - Save off the ns fraction. */ - - /* - * Take the last seven decimal digits and multiply by 100. - * to convert from 100ns units to 1ns units. - */ - ret.tv_nsec = (long) ((d % (1000 * 1000 * 10)) * 100); - - /* Convert to seconds */ - d /= 1000*1000*10; + ret = nt_time_to_unix_timespec_raw(nt); - /* Now adjust by 369 years to make the secs since 1970 */ - d -= TIME_FIXUP_CONSTANT_INT; - - if (d <= (int64_t)TIME_T_MIN) { + if (ret.tv_sec <= TIME_T_MIN) { ret.tv_sec = TIME_T_MIN; ret.tv_nsec = 0; return ret; } - if (d >= (int64_t)TIME_T_MAX) { + if (ret.tv_sec >= TIME_T_MAX) { ret.tv_sec = TIME_T_MAX; ret.tv_nsec = 0; return ret; } - - ret.tv_sec = (time_t)d; return ret; } @@ -1152,7 +1135,6 @@ NTTIME full_timespec_to_nt_time(const struct timespec *_ts) **/ struct timespec nt_time_to_full_timespec(NTTIME nt) { - int64_t d; struct timespec ret; if (nt == NTTIME_OMIT) { @@ -1169,29 +1151,14 @@ struct timespec nt_time_to_full_timespec(NTTIME nt) nt = NTTIME_MAX; } - d = (int64_t)nt; - /* d is now in 100ns units, since jan 1st 1601". - Save off the ns fraction. */ + ret = nt_time_to_unix_timespec_raw(nt); - /* - * Take the last seven decimal digits and multiply by 100. - * to convert from 100ns units to 1ns units. - */ - ret.tv_nsec = (long) ((d % (1000 * 1000 * 10)) * 100); - - /* Convert to seconds */ - d /= 1000*1000*10; - - /* Now adjust by 369 years to make the secs since 1970 */ - d -= TIME_FIXUP_CONSTANT_INT; - - if (d >= (int64_t)TIME_T_MAX) { + if (ret.tv_sec >= TIME_T_MAX) { ret.tv_sec = TIME_T_MAX; ret.tv_nsec = 0; return ret; } - ret.tv_sec = (time_t)d; return ret; } -- Samba Shared Repository