diff options
author | Fabrice Fontaine <fontaine.fabrice@gmail.com> | 2022-02-14 21:17:39 +0100 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-02-15 13:36:35 -0800 |
commit | fb57ad9b9d107856e5f1c8135da04ffa2f7a11ac (patch) | |
tree | 50b56120715eefaeab8632d8cb16d8e2f19f937d /profiles | |
parent | b5ff08b267445f9407d6eefad86cde45ec3a50a2 (diff) | |
download | bluez-fb57ad9b9d107856e5f1c8135da04ffa2f7a11ac.tar.gz |
build: Fix errors with glibc < 2.25
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:
plugins/autopair.c:20:24: fatal error: sys/random.h: No such file or directory
#include <sys/random.h>
^
To fix this build failure, add util_getrandom and a fallback (borrowed
from pipewire and licensed under MIT):
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/src/pipewire/utils.c
Fixes:
- http://autobuild.buildroot.org/results/6b8870d12e0804d6154230a7322c49416c1dc0e2
Diffstat (limited to 'profiles')
-rw-r--r-- | profiles/health/hdp.c | 4 | ||||
-rw-r--r-- | profiles/health/mcap.c | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c index 9d9d1e824..b6590cd3a 100644 --- a/profiles/health/hdp.c +++ b/profiles/health/hdp.c @@ -16,7 +16,6 @@ #include <stdint.h> #include <stdbool.h> #include <unistd.h> -#include <sys/random.h> #include <glib.h> @@ -33,6 +32,7 @@ #include "src/device.h" #include "src/sdpd.h" #include "src/shared/timeout.h" +#include "src/shared/util.h" #include "btio/btio.h" #include "hdp_types.h" @@ -1490,7 +1490,7 @@ static void *generate_echo_packet(void) if (!buf) return NULL; - if (getrandom(buf, HDP_ECHO_LEN, 0) < 0) { + if (util_getrandom(buf, HDP_ECHO_LEN, 0) < 0) { g_free(buf); return NULL; } diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c index aad0a08a3..5d2bac3d9 100644 --- a/profiles/health/mcap.c +++ b/profiles/health/mcap.c @@ -19,7 +19,6 @@ #include <errno.h> #include <unistd.h> #include <time.h> -#include <sys/random.h> #include <glib.h> @@ -28,6 +27,7 @@ #include "btio/btio.h" #include "src/log.h" #include "src/shared/timeout.h" +#include "src/shared/util.h" #include "mcap.h" @@ -1905,7 +1905,7 @@ gboolean mcap_create_mcl(struct mcap_instance *mi, mcl->state = MCL_IDLE; bacpy(&mcl->addr, addr); set_default_cb(mcl); - if (getrandom(&val, sizeof(val), 0) < 0) { + if (util_getrandom(&val, sizeof(val), 0) < 0) { mcap_instance_unref(mcl->mi); g_free(mcl); return FALSE; @@ -2049,7 +2049,7 @@ static void connect_mcl_event_cb(GIOChannel *chan, GError *gerr, mcl->mi = mcap_instance_ref(mi); bacpy(&mcl->addr, &dst); set_default_cb(mcl); - if (getrandom(&val, sizeof(val), 0) < 0) { + if (util_getrandom(&val, sizeof(val), 0) < 0) { mcap_instance_unref(mcl->mi); g_free(mcl); goto drop; |