Bug#554901: libc6-dev: CPU_ISSET() doesn't use const casts
Package: libc6-dev
Version: 2.10.1-5
Severity: normal
Tags: patch
CPU_ISSET(), defined in bits/sched.h, resolves to CPU_ISSET_S. That
macro contains a cast:
# define __CPU_ISSET_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu < 8 * (setsize) \
? ((((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
& __CPUMASK (__cpu))) != 0 \
: 0; }))
The offending line is the fourth in the macro definition. There's no
reason not to use a (const __cpu_mask *) cast, and the failure to do so
means const cpuset_t's can be handed to CPU_ISSET(). By extension, no
structure containing a cpuset_t can be handed as const to a function
which calls CPU_ISSET() at some point.
I've included a patch. The source package for eglibc (2.10.1) seems to
already have this (via other changes), but it's not present in
/usr/include/bits/sched.h as installed....
----------------------------------------------------------------------
--- sched.h 2009-11-07 03:56:07.000000000 -0500
+++ mysched.h 2009-11-07 03:56:20.000000000 -0500
@@ -154,7 +154,7 @@
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu < 8 * (setsize) \
- ? ((((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
+ ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
& __CPUMASK (__cpu))) != 0 \
: 0; }))
----------------------------------------------------------------------
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (990, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.31.5 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages libc6-dev depends on:
ii libc-dev-bin 2.10.1-5 GNU C Library: Development binarie
ii libc6 2.10.1-5 GNU C Library: Shared libraries
ii linux-libc-dev 2.6.31-1 Linux support headers for userspac
Versions of packages libc6-dev recommends:
ii gcc [c-compiler] 4:4.3.4-1 The GNU C compiler
ii gcc-4.3 [c-compiler] 4.3.4-6 The GNU C compiler
ii gcc-4.4 [c-compiler] 4.4.2-2 The GNU C compiler
Versions of packages libc6-dev suggests:
ii glibc-doc 2.10.1-5 GNU C Library: Documentation
ii manpages-dev 3.22-1 Manual pages about using GNU/Linux
-- no debconf information
Reply to: