Re: [PATCH BlueZ] fix build with glibc < 2.25

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marcel,

Le lun. 14 févr. 2022 à 15:14, Marcel Holtmann <marcel@xxxxxxxxxxxx> a écrit :
>
> Hi Fabrice,
>
> > getrandom and sys/random.h are only available since glibc 2.25:
> > https://www.gnu.org/software/gnulib/manual/html_node/sys_002frandom_002eh.html
> > resulting in the following build failures since version 5.63 and
> > https://git.kernel.org/pub/scm/bluetooth/bluez.git/log/?qt=grep&q=getrandom
> > so put back rand() as a fallback:
> >
> > plugins/autopair.c:20:24: fatal error: sys/random.h: No such file or directory
> > #include <sys/random.h>
> >                        ^
> >
> > Fixes:
> > - http://autobuild.buildroot.org/results/6b8870d12e0804d6154230a7322c49416c1dc0e2
> >
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@xxxxxxxxx>
> > ---
> > configure.ac           |  2 ++
> > emulator/le.c          |  7 +++++++
> > emulator/phy.c         |  7 +++++++
> > peripheral/main.c      | 10 ++++++++++
> > plugins/autopair.c     |  6 ++++++
> > profiles/health/hdp.c  | 11 +++++++++++
> > profiles/health/mcap.c | 10 ++++++++++
> > tools/btgatt-server.c  |  6 ++++++
> > 8 files changed, 59 insertions(+)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 07d068a4d..cdd693da3 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -54,6 +54,8 @@ AC_ARG_ENABLE(threads, AS_HELP_STRING([--enable-threads],
> >
> > AC_CHECK_FUNCS(explicit_bzero)
> >
> > +AC_CHECK_FUNCS(getrandom)
> > +
> > AC_CHECK_FUNCS(rawmemchr)
> >
> > AC_CHECK_FUNC(signalfd, dummy=yes,
> > diff --git a/emulator/le.c b/emulator/le.c
> > index f8f313f2c..9ef0636d0 100644
> > --- a/emulator/le.c
> > +++ b/emulator/le.c
> > @@ -20,7 +20,9 @@
> > #include <sys/socket.h>
> > #include <sys/un.h>
> > #include <sys/uio.h>
> > +#ifdef HAVE_GETRANDOM
> > #include <sys/random.h>
> > +#endif
> > #include <time.h>
> >
> > #include "lib/bluetooth.h"
> > @@ -509,10 +511,15 @@ static unsigned int get_adv_delay(void)
> >       /* The advertising delay is a pseudo-random value with a range
> >        * of 0 ms to 10 ms generated for each advertising event.
> >        */
> > +#ifdef HAVE_GETRANDOM
> >       if (getrandom(&val, sizeof(val), 0) < 0) {
> >               /* If it fails to get the random number, use a static value */
> >               val = 5;
> >       }
> > +#else
> > +     srand(time(NULL));
> > +     val = rand();
> > +#endif
>
> you need to introduce a src/missing.h and provide a getrandom fallback. I am not allowing to spread #ifdef around the code for some old glibc compatibility.
OK, I'll send a v2.
>
> Regards
>
> Marcel
>
Best Regards,

Fabrice




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux