linux: __get_nprocs_sched: initialize cpu_bits array with zeroes [BZ #28850]
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
---
sysdeps/unix/sysv/linux/getsysstats.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Tue, Feb 01, 2022 at 09:56:44PM +0000, Gleb Fotengauer-Malinovskiy wrote:
> ---
> sysdeps/unix/sysv/linux/getsysstats.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
> index 4798cc337e..5436bdb507 100644
> --- a/sysdeps/unix/sysv/linux/getsysstats.c
> +++ b/sysdeps/unix/sysv/linux/getsysstats.c
> @@ -41,6 +41,7 @@ __get_nprocs_sched (void)
>
> /* This cannot use malloc because it is used on malloc initialization. */
> __cpu_mask cpu_bits[cpu_bits_size / sizeof (__cpu_mask)];
> + CPU_ZERO_S(cpu_bits_size, cpu_bits);
Good catch!
Please cast cpu_bits to "cpu_set_t*" to make this CPU_ZERO_S invocation
consistent with the CPU_COUNT_S invocation below.
Also, please add a space between CPU_ZERO_S and the opening parenthesis.
@@ -41,6 +41,7 @@ __get_nprocs_sched (void)
/* This cannot use malloc because it is used on malloc initialization. */
__cpu_mask cpu_bits[cpu_bits_size / sizeof (__cpu_mask)];
+ CPU_ZERO_S(cpu_bits_size, cpu_bits);
int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size,
cpu_bits);
if (r > 0)