Skip to content

Commit c80afea

Browse files
committed
acl_threadsupport: fix integer conversion warning
Use same type for cpu as glibc CPU_SET(3). Signed-off-by: Peter Colberg <[email protected]>
1 parent 79228be commit c80afea

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/acl_threadsupport/src/acl_threadsupport.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,15 @@ int acl_tls_set(acl_tls_key_t key, const void *data) {
119119
void acl_set_process_affinity_mask(unsigned long long process_affinity_mask) {
120120
cpu_set_t mask;
121121
CPU_ZERO(&mask);
122-
int i = 0;
122+
// While the Linux man page for CPU_SET(3) states that the cpu argument
123+
// is of type int, glibc changed this macro to use type size_t instead.
124+
// https://man7.org/linux/man-pages/man3/CPU_SET.3.html
125+
// https://sourceware.org/git/?p=glibc.git;a=commit;h=2b7e92df930b8ed1ace659bf6e0b8dff41d65bf0
126+
size_t cpu = 0;
123127
while (process_affinity_mask > 0) {
124128
if (process_affinity_mask % 2)
125-
CPU_SET(i, &mask);
126-
i++;
129+
CPU_SET(cpu, &mask);
130+
cpu++;
127131
process_affinity_mask >>= 1;
128132
}
129133
sched_setaffinity(0, sizeof(mask), &mask);

0 commit comments

Comments
 (0)