diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-01-21 15:46:20 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-01-21 15:46:20 +0000 |
commit | 2746b131aa482ac17c94bc6b82e58dbcc1b752cf (patch) | |
tree | 87e50c57bc8458b0809c280ab5d00042d1102925 /src/librandom | |
parent | 05db4ba46ae1ca6143bb9b432d1e05e69eddd263 (diff) | |
download | skalibs-2746b131aa482ac17c94bc6b82e58dbcc1b752cf.tar.gz skalibs-2746b131aa482ac17c94bc6b82e58dbcc1b752cf.tar.xz skalibs-2746b131aa482ac17c94bc6b82e58dbcc1b752cf.zip |
Types fix: librandom, libstdcrypto
Diffstat (limited to 'src/librandom')
-rw-r--r-- | src/librandom/random_makeseed.c | 3 | ||||
-rw-r--r-- | src/librandom/random_name.c | 2 | ||||
-rw-r--r-- | src/librandom/random_sauniquename.c | 5 | ||||
-rw-r--r-- | src/librandom/random_string.c | 10 | ||||
-rw-r--r-- | src/librandom/random_uint32.c | 9 | ||||
-rw-r--r-- | src/librandom/random_unsort.c | 6 | ||||
-rw-r--r-- | src/librandom/surf.c | 14 |
7 files changed, 27 insertions, 22 deletions
diff --git a/src/librandom/random_makeseed.c b/src/librandom/random_makeseed.c index 909e896..00def5b 100644 --- a/src/librandom/random_makeseed.c +++ b/src/librandom/random_makeseed.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <unistd.h> +#include <stdint.h> #include <skalibs/uint32.h> #include <skalibs/tai.h> #include <skalibs/sha1.h> @@ -19,7 +20,7 @@ void random_makeseed (char *s) { tain_t now ; char tmp[256] ; - uint32 x = getpid() ; + uint32_t x = getpid() ; uint32_pack(tmp, x) ; x = getppid() ; uint32_pack(tmp + 4, x) ; diff --git a/src/librandom/random_name.c b/src/librandom/random_name.c index 83b1626..f972e93 100644 --- a/src/librandom/random_name.c +++ b/src/librandom/random_name.c @@ -4,7 +4,7 @@ #include <skalibs/random.h> -void random_name (char *s, unsigned int n) +void random_name (char *s, size_t n) { static char const oklist[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz-_0123456789abcdef" ; random_string(s, n) ; diff --git a/src/librandom/random_sauniquename.c b/src/librandom/random_sauniquename.c index 6d200aa..e63e46c 100644 --- a/src/librandom/random_sauniquename.c +++ b/src/librandom/random_sauniquename.c @@ -2,13 +2,14 @@ /* MT-unsafe */ +#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> #include <skalibs/random.h> -int random_sauniquename (stralloc *sa, unsigned int n) +int random_sauniquename (stralloc *sa, size_t n) { - unsigned int base = sa->len ; + size_t base = sa->len ; int wasnull = !sa->s ; if (!sauniquename(sa)) return 0 ; if (!stralloc_readyplus(sa, n+1)) goto err ; diff --git a/src/librandom/random_string.c b/src/librandom/random_string.c index 6ccd865..5053824 100644 --- a/src/librandom/random_string.c +++ b/src/librandom/random_string.c @@ -8,7 +8,7 @@ #include <stdlib.h> #include <skalibs/random.h> -void random_string (char *s, unsigned int n) +void random_string (char *s, size_t n) { arc4random_buf(s, n) ; } @@ -27,7 +27,7 @@ static int getrandom (void *buf, size_t buflen, unsigned int flags) return syscall(SYS_getrandom, buf, buflen, flags) ; } -void random_string (char *s, unsigned int n) +void random_string (char *s, size_t n) { while (n) { @@ -47,9 +47,9 @@ void random_string (char *s, unsigned int n) #include <skalibs/random.h> #include "random-internal.h" -void random_string (char *s, unsigned int n) +void random_string (char *s, size_t n) { - unsigned int r = allread(random_fd, s, n) ; + size_t r = allread(random_fd, s, n) ; if (r < n) surf(&surf_here, s+r, n-r) ; } @@ -58,7 +58,7 @@ void random_string (char *s, unsigned int n) #include <skalibs/random.h> #include "random-internal.h" -void random_string (char *s, unsigned int n) +void random_string (char *s, size_t n) { surf(&surf_here, s, n) ; } diff --git a/src/librandom/random_uint32.c b/src/librandom/random_uint32.c index 9009a59..a2144f1 100644 --- a/src/librandom/random_uint32.c +++ b/src/librandom/random_uint32.c @@ -5,23 +5,24 @@ #ifdef SKALIBS_HASARC4RANDOM #include <skalibs/nonposix.h> +#include <stdint.h> #include <stdlib.h> -#include <skalibs/uint32.h> #include <skalibs/random.h> -uint32 random_uint32 (uint32 n) +uint32_t random_uint32 (uint32_t n) { return arc4random_uniform(n) ; } #else +#include <stdint.h> #include <skalibs/uint32.h> #include <skalibs/random.h> -uint32 random_uint32 (uint32 n) +uint32_t random_uint32 (uint32_t n) { - uint32 min, x ; + uint32_t min, x ; if (n < 2) return 0 ; min = -n % n ; for (;;) diff --git a/src/librandom/random_unsort.c b/src/librandom/random_unsort.c index 22c4e08..98a4b09 100644 --- a/src/librandom/random_unsort.c +++ b/src/librandom/random_unsort.c @@ -1,15 +1,15 @@ /* ISC license. */ -#include <skalibs/uint32.h> +#include <stdint.h> #include <skalibs/bytestr.h> #include <skalibs/random.h> -void random_unsort (char *s, unsigned int n, unsigned int chunksize) +void random_unsort (char *s, size_t n, size_t chunksize) { char tmp[chunksize] ; while (n--) { - register uint32 i = random_uint32(n+1) ; + register uint32_t i = random_uint32(n+1) ; byte_copy(tmp, chunksize, s + i * chunksize) ; byte_copy(s + i * chunksize, chunksize, s + n * chunksize) ; byte_copy(s + n * chunksize, chunksize, tmp) ; diff --git a/src/librandom/surf.c b/src/librandom/surf.c index ad0aab1..fe5346e 100644 --- a/src/librandom/surf.c +++ b/src/librandom/surf.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <skalibs/uint32.h> #include <skalibs/bytestr.h> #include <skalibs/surf.h> @@ -9,10 +11,10 @@ static void surfit (SURFSchedule *ctx) { - uint32 t[12] ; - uint32 z[8] ; - uint32 x ; - uint32 sum = 0 ; + uint32_t t[12] ; + uint32_t z[8] ; + uint32_t x ; + uint32_t sum = 0 ; unsigned int i = 0, loop = 0 ; ; if (!++ctx->in[0] && !++ctx->in[1] && !++ctx->in[2]) ++ctx->in[3] ; @@ -33,10 +35,10 @@ static void surfit (SURFSchedule *ctx) for (i = 0 ; i < 8 ; i++) uint32_pack(ctx->out + (i<<2), z[i]) ; } -void surf (SURFSchedule *ctx, char *s, unsigned int n) +void surf (SURFSchedule *ctx, char *s, size_t n) { { - register unsigned int i = 32 - ctx->pos ; + register size_t i = 32 - ctx->pos ; if (n < i) i = n ; byte_copy(s, i, ctx->out + ctx->pos) ; s += i ; n -= i ; ctx->pos += i ; |