Mesa (10.4): auxilary/os: correct sysctl use in os_get_total_physical_memory()

Emil Velikov evelikov at kemper.freedesktop.org
Wed Mar 4 02:02:53 UTC 2015


Module: Mesa
Branch: 10.4
Commit: da46b1b160cc56e908f058b0e11c129aa3a66704
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=da46b1b160cc56e908f058b0e11c129aa3a66704

Author: Jonathan Gray <jsg at jsg.id.au>
Date:   Sun Feb 22 19:19:25 2015 +1100

auxilary/os: correct sysctl use in os_get_total_physical_memory()

The length argument passed to sysctl was the size of the pointer
not the type.  The result of this is sysctl calls would fail on
32 bit BSD/Mac OS X.

Additionally the wrong pointer was passed as an argument to store
the result of the sysctl call.

Cc: "10.4, 10.5" <mesa-stable at lists.freedesktop.org>
Signed-off-by: Jonathan Gray <jsg at jsg.id.au>
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
(cherry picked from commit 7983a3d2e06b0bc16c1a16bddccc7f14fe1f132c)

---

 src/gallium/auxiliary/os/os_misc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/os/os_misc.c b/src/gallium/auxiliary/os/os_misc.c
index ebf033c..c46078b 100644
--- a/src/gallium/auxiliary/os/os_misc.c
+++ b/src/gallium/auxiliary/os/os_misc.c
@@ -118,7 +118,7 @@ os_get_total_physical_memory(uint64_t *size)
    *size = phys_pages * page_size;
    return (phys_pages > 0 && page_size > 0);
 #elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD)
-   size_t len = sizeof(size);
+   size_t len = sizeof(*size);
    int mib[2];
 
    mib[0] = CTL_HW;
@@ -134,7 +134,7 @@ os_get_total_physical_memory(uint64_t *size)
 #error Unsupported *BSD
 #endif
 
-   return (sysctl(mib, 2, &size, &len, NULL, 0) == 0);
+   return (sysctl(mib, 2, size, &len, NULL, 0) == 0);
 #elif defined(PIPE_OS_HAIKU)
    system_info info;
    status_t ret;




More information about the mesa-commit mailing list