git: f394d9c0a40f - main - sysctl: use correct types and names in sysctl_*sec_to_sbintime

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Fri, 27 Jan 2023 15:10:16 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=f394d9c0a40f038facc2b96083e094230aa2d608

commit f394d9c0a40f038facc2b96083e094230aa2d608
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-01-27 15:09:22 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-01-27 15:09:22 +0000

    sysctl: use correct types and names in sysctl_*sec_to_sbintime
    
    The functions are intended to report kernel variables that are
    stored as sbintime_t (pointed to by arg1) as human readable
    nanoseconds or milliseconds (reported via sysctl_handle_64).
    The variable types and names were reversed.  I guess there is
    no functional change here, as all types flipped around were
    signed 64.  Note that these function aren't used yet anywhere
    in the kernel.
    
    Reviewed by:            mav
    Differential revision:  https://reviews.freebsd.org/D38217
---
 sys/kern/kern_sysctl.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 6427ff0c7ecf..430fa87ef0eb 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1889,47 +1889,41 @@ retry:
 }
 
 /*
- * Based on on sysctl_handle_int() convert microseconds to a sbintime.
+ * Based on on sysctl_handle_64() convert microseconds to a sbintime.
  */
 int
 sysctl_usec_to_sbintime(SYSCTL_HANDLER_ARGS)
 {
 	int error;
-	int64_t tt;
-	sbintime_t sb;
+	int64_t usec;
 
-	tt = *(int64_t *)arg1;
-	sb = sbttous(tt);
+	usec = sbttous(*(sbintime_t *)arg1);
 
-	error = sysctl_handle_64(oidp, &sb, 0, req);
+	error = sysctl_handle_64(oidp, &usec, 0, req);
 	if (error || !req->newptr)
 		return (error);
 
-	tt = ustosbt(sb);
-	*(int64_t *)arg1 = tt;
+	*(sbintime_t *)arg1 = ustosbt(usec);
 
 	return (0);
 }
 
 /*
- * Based on on sysctl_handle_int() convert milliseconds to a sbintime.
+ * Based on on sysctl_handle_64() convert milliseconds to a sbintime.
  */
 int
 sysctl_msec_to_sbintime(SYSCTL_HANDLER_ARGS)
 {
 	int error;
-	int64_t tt;
-	sbintime_t sb;
+	int64_t msec;
 
-	tt = *(int64_t *)arg1;
-	sb = sbttoms(tt);
+	msec = sbttoms(*(sbintime_t *)arg1);
 
-	error = sysctl_handle_64(oidp, &sb, 0, req);
+	error = sysctl_handle_64(oidp, &msec, 0, req);
 	if (error || !req->newptr)
 		return (error);
 
-	tt = mstosbt(sb);
-	*(int64_t *)arg1 = tt;
+	*(sbintime_t *)arg1 = mstosbt(msec);
 
 	return (0);
 }