Skip to content

Commit

Permalink
rename: avoid undefined function prototype for fpurge
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Patrick Steinhardt <[email protected]>
  • Loading branch information
pks-t authored and karelzak committed Oct 4, 2018
1 parent 6529212 commit d2523d3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion misc-utils/rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit d2523d3

Please sign in to comment.