/* SPDX-License-Identifier: LGPL-2.1-only */ /* Copyright (C) 2020 Gediminas Jakutis */ #include #include #include #include "datagen.h" #include "defs.h" static struct entry_l buf; struct entry_l *gen_get_array(struct stream * const in, struct entry_l * const store) { struct entry_l *ret; int errn; (void) in; /* lol says librin, lmao */ if (getrandom(&buf.val, sizeof(buf.val), 0ul) == sizeof(buf.val)) { *store = buf; ret = store; } else { errn = errno; ret = NULL; rin_err("error reading urandom: %s", strerror(errn)); } return ret; } struct entry_l *gen_get_list(struct stream * const in, struct entry_l * const store) { struct entry_l *ret; try_s((ret = gen_get_array(in, store)), err); ret->next = NULL; err: return ret; }