Mesa (main): util: Trivial cleanup in the BSD code of util_cpu_detect_once

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 15 20:26:14 UTC 2021


Module: Mesa
Branch: main
Commit: 44246892a0c2993a338dd5e11d07792bfe05ece9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=44246892a0c2993a338dd5e11d07792bfe05ece9

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Jun  8 15:33:39 2021 -0700

util: Trivial cleanup in the BSD code of util_cpu_detect_once

This code is going to be replicated in future commits, so tidy up a bit
first.

Acked-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11228>

---

 src/util/u_cpu_detect.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/util/u_cpu_detect.c b/src/util/u_cpu_detect.c
index b60ce165702..5890fcf59f3 100644
--- a/src/util/u_cpu_detect.c
+++ b/src/util/u_cpu_detect.c
@@ -571,13 +571,10 @@ util_cpu_detect_once(void)
       util_cpu_caps.nr_cpus = 1;
 #  elif defined(PIPE_OS_BSD)
    {
-      int mib[2], ncpu;
-      int len;
+      const int mib[] = { CTL_HW, HW_NCPU };
+      int ncpu;
+      int len = sizeof(ncpu);
 
-      mib[0] = CTL_HW;
-      mib[1] = HW_NCPU;
-
-      len = sizeof (ncpu);
       sysctl(mib, 2, &ncpu, &len, NULL, 0);
       util_cpu_caps.nr_cpus = ncpu;
    }



More information about the mesa-commit mailing list