Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Sep 2022 02:04:15 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: a26c4766b029 - stable/13 - libthr: use nitems() for mib length
Message-ID:  <202209300204.28U24FGH099241@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

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

commit a26c4766b02993b664b8934d764e36e6472c8ccc
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-09-12 20:24:55 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-09-30 00:29:10 +0000

    libthr: use nitems() for mib length
    
    (cherry picked from commit ebf7a01594eeb8c2897d1b310069df35da112413)
---
 lib/libc/gen/elf_utils.c      | 4 ++--
 lib/libthr/thread/thr_init.c  | 4 ++--
 lib/libthr/thread/thr_stack.c | 5 ++---
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/libc/gen/elf_utils.c b/lib/libc/gen/elf_utils.c
index fbf3bf17082c..ea5cc25f8601 100644
--- a/lib/libc/gen/elf_utils.c
+++ b/lib/libc/gen/elf_utils.c
@@ -28,7 +28,7 @@
  * $FreeBSD$
  */
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/mman.h>
 #include <sys/resource.h>
 #include <sys/sysctl.h>
@@ -83,7 +83,7 @@ __libc_map_stacks_exec(void)
 	mib[0] = CTL_KERN;
 	mib[1] = KERN_USRSTACK;
 	len = sizeof(usrstack);
-	if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), &usrstack, &len, NULL, 0)
+	if (sysctl(mib, nitems(mib), &usrstack, &len, NULL, 0)
 	    == -1)
 		return;
 	if (getrlimit(RLIMIT_STACK, &rlim) == -1)
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index 82bde10a153e..0ab051e57994 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -37,7 +37,7 @@
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/signalvar.h>
 #include <sys/ioctl.h>
 #include <sys/link_elf.h>
@@ -466,7 +466,7 @@ init_private(void)
 		mib[0] = CTL_KERN;
 		mib[1] = KERN_USRSTACK;
 		len = sizeof (_usrstack);
-		if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1)
+		if (sysctl(mib, nitems(mib), &_usrstack, &len, NULL, 0) == -1)
 			PANIC("Cannot get kern.usrstack from sysctl");
 		env_bigstack = getenv("LIBPTHREAD_BIGSTACK_MAIN");
 		env_splitstack = getenv("LIBPTHREAD_SPLITSTACK_MAIN");
diff --git a/lib/libthr/thread/thr_stack.c b/lib/libthr/thread/thr_stack.c
index b08bafdd9417..af396fe2ba93 100644
--- a/lib/libthr/thread/thr_stack.c
+++ b/lib/libthr/thread/thr_stack.c
@@ -30,7 +30,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/mman.h>
 #include <sys/queue.h>
 #include <sys/resource.h>
@@ -155,8 +155,7 @@ singlethread_map_stacks_exec(void)
 	mib[0] = CTL_KERN;
 	mib[1] = KERN_USRSTACK;
 	len = sizeof(usrstack);
-	if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), &usrstack, &len, NULL, 0)
-	    == -1)
+	if (sysctl(mib, nitems(mib), &usrstack, &len, NULL, 0) == -1)
 		return;
 	if (getrlimit(RLIMIT_STACK, &rlim) == -1)
 		return;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202209300204.28U24FGH099241>