Skip to contentSkip to conversation

Fixes for v2.33 on musl-based systems

PATCH Applied Patrick Steinhardt 2 participants 4 messages Sep 26, 2018 – Oct 4, 2018 Util-Linux package

lore
Share & tools
lore
#0 lore raw

cover Fixes for v2.33 on musl-based systems

Hi,

there are two small issues I discovered in v2.33-rc1 on musl-based systems. The first patch fixes a compile error, the second patch fixes a warning.

Regards
Patrick

Patrick Steinhardt (2):
lsblk: fix unknown type stat caused by missing header
rename: avoid undefined function prototype for fpurge

 misc-utils/lsblk.h  | 1 +
 misc-utils/rename.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.19.0
#1 lore raw

PATCH 1/2 lsblk: fix unknown type `stat` caused by missing header

The structure blkdev_cxt has a struct stat member embedded, whose size may not be known on some systems because of a missing include for "sys/stat.h". On glibc-based systems, this header is included transitively via "sys/statvfs.h", but on musl-based systems it is not.

Fix the resulting compile error due to unknown size of the struct by including "sys/stat.h".

---
 misc-utils/lsblk.h | 1 +
 1 file changed, 1 insertion(+)
misc-utils/lsblk.h +1 -0
index 6e0186576..baad3aa9b 100644
@@ -8,6 +8,7 @@
 
 #include <stdint.h>
 #include <inttypes.h>
+#include <sys/stat.h>
 #include <sys/statvfs.h>
 
 #include <libsmartcols.h>
Signature · 1 line
2.19.0
#2 lore raw

PATCH 2/2 rename: avoid undefined function prototype for `fpurge`

In reply to Patrick Steinhardt

In case where the non-standard fpurge function is available, we redefine __fpurge to fpurge. We can do so because the only difference between both functions is that one returns an error code while the other does not. But as we do not check the error code either way, we do not care about which one of them we use.

The above redefinition happens unconditionally if we know that fpurge exists. Most notably, we also redefine it if we already do have an __fpurge function available that could be used. This causes problems on musl-based platforms, where we detect availability of fpurge in libc, but where no function declaration for it exists in "stdio_ext.h". The compiler thus prints a warning due to an unknown function, even though it will link just fine.

Avoid this warning by only redefining __fpurge to fpurge when HAVE___FPURGE is not defined.

---
 misc-utils/rename.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
misc-utils/rename.c +3 -1
index 0e3e1b9e1..1d9315793 100644
@@ -17,9 +17,11 @@ for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done
 #ifdef HAVE_STDIO_EXT_H
 #	include <stdio_ext.h>
 #endif
-#ifdef HAVE_FPURGE
+#ifndef HAVE___FPURGE
+# ifdef HAVE_FPURGE
 #	define HAVE___FPURGE 1
 #	define __fpurge fpurge
+# endif
 #endif
 #include <string.h>
 #include <stdlib.h>
Signature · 1 line
2.19.0
maintainer Applied
#3 lore raw
In reply to Patrick Steinhardt
Quoted 3 lines · Patrick Steinhardt

Patrick Steinhardt (2):
lsblk: fix unknown type stat caused by missing header
rename: avoid undefined function prototype for fpurge

Applied, thanks!

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com