Comparison

util-src/crand.c @ 12470:80f3123053e2

util.crand: Reduce scope here too Same as previous commit
author Kim Alvefur <zash@zash.se>
date Sat, 23 Apr 2022 14:37:43 +0200
parent 8451:770f79a9635c
child 12575:1f6f05a98fcd
comparison
equal deleted inserted replaced
12469:2b3adaa6d38e 12470:80f3123053e2
43 #ifndef SYS_getrandom 43 #ifndef SYS_getrandom
44 #error getrandom() requires Linux 3.17 or later 44 #error getrandom() requires Linux 3.17 or later
45 #endif 45 #endif
46 46
47 /* This wasn't present before glibc 2.25 */ 47 /* This wasn't present before glibc 2.25 */
48 int getrandom(void *buf, size_t buflen, unsigned int flags) { 48 static int getrandom(void *buf, size_t buflen, unsigned int flags) {
49 return syscall(SYS_getrandom, buf, buflen, flags); 49 return syscall(SYS_getrandom, buf, buflen, flags);
50 } 50 }
51 #else 51 #else
52 #include <sys/random.h> 52 #include <sys/random.h>
53 #endif 53 #endif
64 64
65 #ifndef SMALLBUFSIZ 65 #ifndef SMALLBUFSIZ
66 #define SMALLBUFSIZ 32 66 #define SMALLBUFSIZ 32
67 #endif 67 #endif
68 68
69 int Lrandom(lua_State *L) { 69 static int Lrandom(lua_State *L) {
70 char smallbuf[SMALLBUFSIZ]; 70 char smallbuf[SMALLBUFSIZ];
71 char *buf = &smallbuf[0]; 71 char *buf = &smallbuf[0];
72 const lua_Integer l = luaL_checkinteger(L, 1); 72 const lua_Integer l = luaL_checkinteger(L, 1);
73 const size_t len = l; 73 const size_t len = l;
74 luaL_argcheck(L, l >= 0, 1, "must be > 0"); 74 luaL_argcheck(L, l >= 0, 1, "must be > 0");