Package: linux-libc-dev
Version: 5.17.3-1
Severity: normal
Tags: upstream
X-Debbugs-Cc: alx.manpa...@gmail.com
I was cleaning up the example programs in the man-pages by using
iwyu(1), when I found that is using 'size_t'
without including any definition for it.
See the following example program:
$ cat tmp/src/man2/sysctl.2.d/sysctl.c
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
int _sysctl(struct __sysctl_args *args );
#define OSNAMESZ 100
int
main(void)
{
struct __sysctl_args args;
char osname[OSNAMESZ];
size_t osnamelth;
int name[] = { CTL_KERN, KERN_OSTYPE };
memset(&args, 0, sizeof(args));
args.name = name;
args.nlen = sizeof(name)/sizeof(name[0]);
args.oldval = osname;
args.oldlenp = &osnamelth;
osnamelth = sizeof(osname);
if (syscall(SYS__sysctl, &args) == -1) {
perror("_sysctl");
exit(EXIT_FAILURE);
}
printf("This machine is running %*s\n", (int) osnamelth, osname);
exit(EXIT_SUCCESS);
}
for which I get the following errors:
$ cc -c -std=gnu17 -Wall -Wextra -Werror -Wno-error=unused-parameter \
-Wno-error=sign-compare -Wno-error=format \
-o tmp/src/man2/sysctl.2.d/sysctl.o \
tmp/src/man2/sysctl.2.d/sysctl.c;
In file included from tmp/src/man2/sysctl.2.d/sysctl.c:3:
/usr/include/linux/sysctl.h:39:9: error: unknown type name 'size_t'
39 | size_t *oldlenp;
| ^~
/usr/include/linux/sysctl.h:41:9: error: unknown type name 'size_t'
41 | size_t newlen;
| ^~
tmp/src/man2/sysctl.2.d/sysctl.c: In function 'main':
tmp/src/man2/sysctl.2.d/sysctl.c:26:18: error: assignment to 'int *'
from incompatible pointer type 'size_t *' {aka 'long unsigned int *'}
[-Werror=incompatible-pointer-types]
26 | args.oldlenp = &osnamelth;
| ^
cc1: all warnings being treated as errors
It seems that it's supposed to know some types, but for some reason
'size_t' is not defined by the included headers:
$ grep include
#include
Cheers,
Alex
-- System Information:
Debian Release: bookworm/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 5.16.0-5-amd64 (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
-- no debconf information