summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shared/util.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 61513bade5..9672b7fcc0 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -208,6 +208,7 @@ int parse_uid(const char *s, uid_t* ret_uid) {
*ret_uid = uid;
return 0;
}
+
int safe_atou(const char *s, unsigned *ret_u) {
char *x = NULL;
unsigned long l;
@@ -338,7 +339,6 @@ const char* split(const char **state, size_t *l, const char *separator, bool quo
return current;
}
-
char *truncate_nl(char *s) {
assert(s);
@@ -427,23 +427,6 @@ int rmdir_parents(const char *path, const char *stop) {
return 0;
}
-int dev_urandom(void *p, size_t n) {
- _cleanup_close_ int fd;
- ssize_t k;
-
- fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC|O_NOCTTY);
- if (fd < 0)
- return errno == ENOENT ? -ENOSYS : -errno;
-
- k = loop_read(fd, p, n, true);
- if (k < 0)
- return (int) k;
- if ((size_t) k != n)
- return -EIO;
-
- return 0;
-}
-
char hexchar(int x) {
static const char table[16] = "0123456789abcdef";
@@ -741,6 +724,23 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) {
return n;
}
+int dev_urandom(void *p, size_t n) {
+ _cleanup_close_ int fd;
+ ssize_t k;
+
+ fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC|O_NOCTTY);
+ if (fd < 0)
+ return errno == ENOENT ? -ENOSYS : -errno;
+
+ k = loop_read(fd, p, n, true);
+ if (k < 0)
+ return (int) k;
+ if ((size_t) k != n)
+ return -EIO;
+
+ return 0;
+}
+
void random_bytes(void *p, size_t n) {
static bool srand_called = false;
uint8_t *q;