Changeset 87337dc5 in mainline for uspace/lib/c/generic/uuid.c
- Timestamp:
- 2018-07-09T15:00:24Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d054ad3
- Parents:
- 914c693
- git-author:
- Jiri Svoboda <jiri@…> (2018-07-08 19:58:56)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-07-09 15:00:24)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/uuid.c
r914c693 r87337dc5 35 35 #include <errno.h> 36 36 #include <uuid.h> 37 #include <rndgen.h> 37 38 #include <stdlib.h> 38 39 #include <stddef.h> 39 #include <time.h>40 40 #include <str.h> 41 41 … … 48 48 { 49 49 int i; 50 struct timeval tv; 50 rndgen_t *rndgen; 51 errno_t rc; 51 52 52 /* XXX This is a rather poor way of generating random numbers */53 gettimeofday(&tv, NULL);54 srand(tv.tv_sec ^ tv.tv_usec);53 rc = rndgen_create(&rndgen); 54 if (rc != EOK) 55 return EIO; 55 56 56 for (i = 0; i < uuid_bytes; i++) 57 uuid->b[i] = rand(); 57 for (i = 0; i < uuid_bytes; i++) { 58 rc = rndgen_uint8(rndgen, &uuid->b[i]); 59 if (rc != EOK) { 60 rc = EIO; 61 goto error; 62 } 63 } 58 64 59 65 /* Version 4 UUID from random or pseudo-random numbers */ … … 62 68 63 69 return EOK; 70 error: 71 rndgen_destroy(rndgen); 72 return rc; 64 73 } 65 74
Note:
See TracChangeset
for help on using the changeset viewer.