util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: util-linux@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>
Subject: [PATCH 2/2] rename: avoid undefined function prototype for `fpurge`
Date: Wed, 26 Sep 2018 08:23:09 +0200	[thread overview]
Message-ID: <9ecf9e8bb7fb7446624711e968fbb3d2f932a7dd.1537942755.git.ps@pks.im> (raw)
In-Reply-To: <cover.1537942755.git.ps@pks.im>

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 <ps@pks.im>
---
 misc-utils/rename.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index 0e3e1b9e1..1d9315793 100644
--- a/misc-utils/rename.c
+++ b/misc-utils/rename.c
@@ -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>
-- 
2.19.0

  parent reply	other threads:[~2018-09-26 12:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26  6:23 [PATCH 0/2] Fixes for v2.33 on musl-based systems Patrick Steinhardt
2018-09-26  6:23 ` [PATCH 1/2] lsblk: fix unknown type `stat` caused by missing header Patrick Steinhardt
2018-09-26  6:23 ` Patrick Steinhardt [this message]
2018-10-04  9:58 ` [PATCH 0/2] Fixes for v2.33 on musl-based systems Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ecf9e8bb7fb7446624711e968fbb3d2f932a7dd.1537942755.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).