summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2021-06-08 15:08:50 -0700
committerMarge Bot <eric+marge@anholt.net>2021-06-15 20:01:52 +0000
commita923e95b10152726a3cdf4bdbc35690425ce9bc3 (patch)
tree818dee47ba47c218b5a7ae2757b7cb16a4486bd6
parent5971f29c8ffe677a2ba2eb70793378f8351dc783 (diff)
util: Zero out all of mask in util_set_thread_affinity
memset operates in bytes, and there are 8-bits in a byte. This is a very easy to miss typo. :( Fixes: 9758b1d416a1 ("util: add util_set_thread_affinity helpers including Windows support") Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11228>
-rw-r--r--src/util/u_thread.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/u_thread.h b/src/util/u_thread.h
index 67383aefe66..013e8be6a6e 100644
--- a/src/util/u_thread.h
+++ b/src/util/u_thread.h
@@ -175,7 +175,7 @@ util_set_thread_affinity(thrd_t thread,
if (pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset) != 0)
return false;
- memset(old_mask, 0, num_mask_bits / 32);
+ memset(old_mask, 0, num_mask_bits / 8);
for (unsigned i = 0; i < num_mask_bits && i < CPU_SETSIZE; i++) {
if (CPU_ISSET(i, &cpuset))
old_mask[i / 32] |= 1u << (i % 32);
@@ -200,7 +200,7 @@ util_set_thread_affinity(thrd_t thread,
return false;
if (old_mask) {
- memset(old_mask, 0, num_mask_bits / 32);
+ memset(old_mask, 0, num_mask_bits / 8);
old_mask[0] = m;
#ifdef _WIN64