Fix build with musl

Andrew Savchenko <[email protected]> Sat, 5 Sep 2020 14:41:30 +0300
Newsgroups gmane.linux.oprofile
Message-ID <[email protected]>
--===============1667191393239906407==
Content-Type: multipart/signed; protocol="application/pgp-signature";
 micalg="PGP-SHA512";
 boundary="Signature=_Sat__5_Sep_2020_14_41_30_+0300_B.qpPPwu83bbA.32"

--Signature=_Sat__5_Sep_2020_14_41_30_+0300_B.qpPPwu83bbA.32
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

When musl is used instead of glibc, oprofile build fails because it
uses glibc-specific FTW extension: FTW_ACTIONRETVAL for custom
__delete_old_previous_sample_data return codes and FTW_STOP,
FTW_CONTINUE for such return codes. Musl supports only POSIX ftw, so
build fails.

However, this extension is not really needed by oprofile, because
FTW_SKIP_* are not used and {FTW_STOP,FTW_CONTINUE} can be handled
by standard return codes {1,0} (more precisely standard defines
{!0,0}, but in glibc FTW_STOP =3D 1, so I keep this value).

Signed-off-by: Andrew Savchenko <[email protected]>
---
 pe_profiling/operf.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
index 06a0ea3c..1b882b7c 100644
--- a/pe_profiling/operf.cpp
+++ b/pe_profiling/operf.cpp
@@ -860,9 +860,9 @@ static int __delete_old_previous_sample_data(const char=
 *fpath,
 {
    if (remove(fpath)) {
        perror("sample data removal error");
-       return FTW_STOP;
+       return 1;
    } else {
-       return FTW_CONTINUE;
+       return 0;
    }
 }

@@ -897,7 +897,7 @@ static void convert_sample_data(void)
        return;

    if (!operf_options::append) {
-                int flags =3D FTW_DEPTH | FTW_ACTIONRETVAL;
+                int flags =3D FTW_DEPTH;
        errno =3D 0;
        if (nftw(previous_sampledir.c_str(), __delete_old_previous_sample_d=
ata, 32, flags) !=3D0 &&
                errno !=3D ENOENT) {
--
2.24.0

Best regards,
Andrew Savchenko

--Signature=_Sat__5_Sep_2020_14_41_30_+0300_B.qpPPwu83bbA.32
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE63ZIHsdeM+1XgNer9lNaM7oe5I0FAl9TeWoACgkQ9lNaM7oe
5I2fMBAAs28Rjoz0irZwZI0AaNFJlp4BsTbzy8IfTOSzBSqeLDFfRLGEXS7hBrHP
afIFbPx/e4yEAlVzd0gvgN42H1B8EIdmDnQ/WIGtSqSY3zKuVknNiBG4spDFdrRk
hwKZ/3saLQEJQGbtETaUP2uAy40BoHxCVmxbe+0YRlONnm50iKYsmyxT/1QSb1JZ
O+2CZ6tJ1KXjWqdSVPQc76es/M9AZX5O+dYRAeJs5SKWUeMiEKCGhC0Pvc0uKJR0
RdBtww5zCzJ++xwd8IqWStps0OH0k1Qj8V2vO62rZayv6IVHPV+EPccYgSHCcZDy
GqS2R2p9fPt6ojr+2PayOj8mIGdiSCcv2/JI4YtpDyqky/kJSm1MfCX9jQP5qzEV
fQhODF8k8/ZHQ9ZvjNrbIN38JXTy3KdNLAYJKezJ/gcyic3YrsbVV5jh8Zli6bvt
Q5XLuELsaSwzAs2Ehu0xJRhLbIofYeJ5qOG0axOWq7lBVd3l0XqZ8lCKt2p76rjy
SFgyys5PdEuu5eNjmgBAYJDztVmdf/e5+A65M6H2e1RR9BUCHuatitiQzEpCVfwQ
nj1GWbBupjEsVNbZ1qQgPyudB9F9PlOCyt104cl8JO2+8447PSBYtYIGdkMnZqa4
G3IzfTpZ3PImRzxAF4fGHhE/HHZuVt7ahBB+LNTxcfglNERlsTY=
=83jN
-----END PGP SIGNATURE-----

--Signature=_Sat__5_Sep_2020_14_41_30_+0300_B.qpPPwu83bbA.32--


--===============1667191393239906407==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============1667191393239906407==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
oprofile-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oprofile-list

--===============1667191393239906407==--