From f504663a1688353df9ca807108b5181847e902e5 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Wed, 9 Dec 2020 23:10:54 +0100 Subject: [PATCH] devices: Include `sys/sysmacros.h` for `major()` and `minor()` Building the source on Debian sid/unstable with libc6 2.31-5 and UUID support (default) results in the build failure below. CC tiny_initramfs-devices.o CC tiny_initramfs-util.o devices.c: In function 'scan_devices': devices.c:290:15: warning: implicit declaration of function 'major' [-Wimplicit-function-declaration] 290 | if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) { | ^~~~~ devices.c:290:33: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] 290 | if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) { | ^~ devices.c:290:43: warning: implicit declaration of function 'minor' [-Wimplicit-function-declaration] 290 | if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) { | ^~~~~ devices.c:290:61: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] 290 | if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) { | ^~ CCLD tiny_initramfs /usr/bin/ld: tiny_initramfs-devices.o: in function `scan_devices': devices.c:(.text+0x520): undefined reference to `major' /usr/bin/ld: devices.c:(.text+0x539): undefined reference to `minor' collect2: error: ld returned 1 exit status make[1]: *** [Makefile:398: tiny_initramfs] Error 1 Explicitly include the header `sys/sysmacros.h`, where `major()` and `minor()` are defined. Resolves: https://github.com/chris-se/tiny-initramfs/issues/4 --- devices.c | 1 + 1 file changed, 1 insertion(+) diff --git a/devices.c b/devices.c index 78bff1d..fa2f68f 100644 --- a/devices.c +++ b/devices.c @@ -36,6 +36,7 @@ #include #include #include +#include /* Not all libcs define these things, unfortunately... */ #ifndef DT_UNKNOWN