Skip to content

Commit

Permalink
devices: Include sys/sysmacros.h for major() and minor()
Browse files Browse the repository at this point in the history
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: chris-se#4
  • Loading branch information
paulmenzel committed Dec 9, 2020
1 parent e593718 commit 2395f5b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "tiny_initramfs.h"

#include <sys/time.h>
#include <sys/sysmacros.h>
#include <time.h>
#include <errno.h>
#include <string.h>
Expand Down

0 comments on commit 2395f5b

Please sign in to comment.