summaryrefslogtreecommitdiff
path: root/src/sysdeps/trydevurandom.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-03-15 09:32:36 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-03-15 09:32:36 +0000
commita36a3eb159d88507705253577814a8fdcb2a86d1 (patch)
tree7b1af1e5909b330f4a602fc20229c3911dd0b233 /src/sysdeps/trydevurandom.c
parent329aee76f71ca3fdc832e14e1b4ef7309e97e638 (diff)
downloadskalibs-a36a3eb159d88507705253577814a8fdcb2a86d1.tar.xz
sysdeps tests cleanup. (I expect BSDs to break, as usual.)
Diffstat (limited to 'src/sysdeps/trydevurandom.c')
-rw-r--r--src/sysdeps/trydevurandom.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/sysdeps/trydevurandom.c b/src/sysdeps/trydevurandom.c
index 3d0f912..9c56e94 100644
--- a/src/sysdeps/trydevurandom.c
+++ b/src/sysdeps/trydevurandom.c
@@ -1,22 +1,11 @@
/* ISC license. */
+#include <string.h>
#include <unistd.h>
-#include <sys/types.h>
#include <fcntl.h>
+#include <sys/stat.h>
-static int byte_diff (char *s, unsigned int n, char *t)
-{
- for (;;)
- {
- if (!n) return 0 ;
- if (*s != *t) break ;
- ++s ; ++t ; --n ;
- }
- return ((int)(unsigned int)(unsigned char) *s)
- - ((int)(unsigned int)(unsigned char) *t);
-}
-
-int main ()
+int main (void)
{
char a[64] ;
char b[64] ;
@@ -27,5 +16,5 @@ int main ()
fd = open("/dev/urandom", O_RDONLY) ;
if ((fd == -1) || (read(fd, b, 64) < 64) ) return 111 ;
close(fd) ;
- return (!byte_diff(a, 64, b)) ;
+ return (!memcmp(a, 64, b)) ;
}