From 18ba21270942852a296ed9b4c7e8b58346c1bf89 Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 13 May 2020 01:42:09 -0400 Subject: [PATCH] qrcode demo: use arc4rand() on freebsd #601 --- src/demo/qrcode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/demo/qrcode.c b/src/demo/qrcode.c index 2f7d32d4d..11c5d8e2b 100644 --- a/src/demo/qrcode.c +++ b/src/demo/qrcode.c @@ -1,5 +1,9 @@ #include "demo.h" +#ifdef __linux__ #include +#else +#include +#endif int qrcode_demo(struct notcurses* nc){ #ifdef USE_QRCODEGEN @@ -9,10 +13,14 @@ int qrcode_demo(struct notcurses* nc){ for(int i = 0 ; i < 1024 ; ++i){ ncplane_erase(n); size_t len = random() % sizeof(data) + 1; +#ifdef __linux__ ssize_t got = getrandom(data, len, 0); if(got < 0 || (size_t)got != len){ return -1; } +#else + arc4rand(data, len, 0); +#endif if(ncplane_cursor_move_yx(n, 0, 0)){ return -1; }