summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2014-08-05 17:03:25 -0400
committerAnthony G. Basile <blueness@gentoo.org>2014-08-05 17:03:25 -0400
commit4b8733ffe9c0fe8e5a527186d323dab93e43fb37 (patch)
tree54e6e64995f65e619fdbd9a40b2b1e83244507b7 /src
parente35ef44ebe788aaffd1f6910750492bacaba7b6f (diff)
src/{libudev,udev}: minor renamings from upstream
Diffstat (limited to 'src')
-rw-r--r--src/libudev/device-nodes.c4
-rw-r--r--src/libudev/exit-status.c2
-rw-r--r--src/libudev/exit-status.h2
-rw-r--r--src/libudev/fileio.c8
-rw-r--r--src/libudev/fileio.h2
-rw-r--r--src/libudev/log.h2
-rw-r--r--src/libudev/macro.h7
-rw-r--r--src/libudev/strv.c17
-rw-r--r--src/libudev/strv.h1
-rw-r--r--src/libudev/time-util.c8
-rw-r--r--src/libudev/time-util.h44
-rw-r--r--src/udev/dev-setup.c18
-rw-r--r--src/udev/dev-setup.h2
13 files changed, 63 insertions, 54 deletions
diff --git a/src/libudev/device-nodes.c b/src/libudev/device-nodes.c
index 9efafaf548..5ddcaf042c 100644
--- a/src/libudev/device-nodes.c
+++ b/src/libudev/device-nodes.c
@@ -3,7 +3,7 @@
/***
This file is part of eudev, forked from systemd.
- Copyright 2012 Lennart Poettering
+ Copyright 2008-2011 Kay Sievers
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
@@ -21,8 +21,8 @@
#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include <stdint.h>
+#include <string.h>
#include <sys/types.h>
#include "device-nodes.h"
diff --git a/src/libudev/exit-status.c b/src/libudev/exit-status.c
index 1db11d3407..79bb8ca981 100644
--- a/src/libudev/exit-status.c
+++ b/src/libudev/exit-status.c
@@ -31,7 +31,7 @@ bool is_clean_exit(int code, int status, ExitStatusSet *success_status) {
if (code == CLD_EXITED)
return status == 0 ||
(success_status &&
- set_contains(success_status->code, INT_TO_PTR(status)));
+ set_contains(success_status->status, INT_TO_PTR(status)));
/* If a daemon does not implement handlers for some of the
* signals that's not considered an unclean shutdown */
diff --git a/src/libudev/exit-status.h b/src/libudev/exit-status.h
index c8bda70a8a..e2570c65d2 100644
--- a/src/libudev/exit-status.h
+++ b/src/libudev/exit-status.h
@@ -24,7 +24,7 @@
#include "set.h"
typedef struct ExitStatusSet {
- Set *code;
+ Set *status;
Set *signal;
} ExitStatusSet;
diff --git a/src/libudev/fileio.c b/src/libudev/fileio.c
index 8eb834dcd0..fe27b23001 100644
--- a/src/libudev/fileio.c
+++ b/src/libudev/fileio.c
@@ -25,8 +25,12 @@
#include "utf8.h"
#include "ctype.h"
-int write_string_to_file(FILE *f, const char *line) {
+int write_string_stream(FILE *f, const char *line) {
+ assert(f);
+ assert(line);
+
errno = 0;
+
fputs(line, f);
if (!endswith(line, "\n"))
fputc('\n', f);
@@ -49,7 +53,7 @@ int write_string_file(const char *fn, const char *line) {
if (!f)
return -errno;
- return write_string_to_file(f, line);
+ return write_string_stream(f, line);
}
int read_one_line_file(const char *fn, char **line) {
_cleanup_fclose_ FILE *f = NULL;
diff --git a/src/libudev/fileio.h b/src/libudev/fileio.h
index c7997c58a2..55c5d92486 100644
--- a/src/libudev/fileio.h
+++ b/src/libudev/fileio.h
@@ -21,7 +21,7 @@
#include "macro.h"
-int write_string_to_file(FILE *f, const char *line);
+int write_string_stream(FILE *f, const char *line);
int write_string_file(const char *fn, const char *line);
int read_one_line_file(const char *fn, char **line);
int read_full_file(const char *fn, char **contents, size_t *size);
diff --git a/src/libudev/log.h b/src/libudev/log.h
index 45a4f9c2f0..1b2a67a030 100644
--- a/src/libudev/log.h
+++ b/src/libudev/log.h
@@ -21,9 +21,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <syslog.h>
#include <stdbool.h>
#include <stdarg.h>
+#include <syslog.h>
#include <errno.h>
#include "macro.h"
diff --git a/src/libudev/macro.h b/src/libudev/macro.h
index ac2a23f6aa..2deaf04092 100644
--- a/src/libudev/macro.h
+++ b/src/libudev/macro.h
@@ -64,7 +64,6 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
return ((l + ali - 1) & ~(ali - 1));
}
-#define ALIGN_TO_PTR(p, ali) ((void*) ALIGN_TO((unsigned long) p))
#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
@@ -100,12 +99,6 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
} while (false)
-#if defined(static_assert)
-#define assert_cc(expr) static_assert(expr, #expr)
-#else
-#define assert_cc(expr) struct UNIQUE(_assert_struct_) { char x[(expr) ? 0 : -1]; };
-#endif
-
#define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
#define INT_TO_PTR(u) ((void *) ((intptr_t) (u)))
#define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
diff --git a/src/libudev/strv.c b/src/libudev/strv.c
index cbfe2388d6..da8ea8a0a6 100644
--- a/src/libudev/strv.c
+++ b/src/libudev/strv.c
@@ -161,9 +161,18 @@ int strv_push(char ***l, char *value) {
return 0;
}
+int strv_consume(char ***l, char *value) {
+ int r;
+
+ r = strv_push(l, value);
+ if (r < 0)
+ free(value);
+
+ return r;
+}
+
int strv_extend(char ***l, const char *value) {
char *v;
- int r;
if (!value)
return 0;
@@ -172,11 +181,7 @@ int strv_extend(char ***l, const char *value) {
if (!v)
return -ENOMEM;
- r = strv_push(l, v);
- if (r < 0)
- free(v);
-
- return r;
+ return strv_consume(l, v);
}
char **strv_uniq(char **l) {
diff --git a/src/libudev/strv.h b/src/libudev/strv.h
index 12fa9f0524..4cc918367e 100644
--- a/src/libudev/strv.h
+++ b/src/libudev/strv.h
@@ -39,6 +39,7 @@ unsigned strv_length(char * const *l) _pure_;
int strv_extend(char ***l, const char *value);
int strv_push(char ***l, char *value);
+int strv_consume(char ***l, char *value);
char **strv_remove(char **l, const char *s);
char **strv_uniq(char **l);
diff --git a/src/libudev/time-util.c b/src/libudev/time-util.c
index d7682773c4..6f76e8c19b 100644
--- a/src/libudev/time-util.c
+++ b/src/libudev/time-util.c
@@ -38,10 +38,10 @@ usec_t timespec_load(const struct timespec *ts) {
if (ts->tv_sec == (time_t) -1 &&
ts->tv_nsec == (long) -1)
- return (usec_t) -1;
+ return USEC_INFINITY;
if ((usec_t) ts->tv_sec > (UINT64_MAX - (ts->tv_nsec / NSEC_PER_USEC)) / USEC_PER_SEC)
- return (usec_t) -1;
+ return USEC_INFINITY;
return
(usec_t) ts->tv_sec * USEC_PER_SEC +
@@ -71,7 +71,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
assert(buf);
assert(l > 0);
- if (t == (usec_t) -1)
+ if (t == USEC_INFINITY)
return NULL;
if (t <= 0) {
@@ -83,7 +83,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
/* The result of this function can be parsed with parse_sec */
for (i = 0; i < ELEMENTSOF(table); i++) {
- int k;
+ int k = 0;
size_t n;
bool done = false;
usec_t a, b;
diff --git a/src/libudev/time-util.h b/src/libudev/time-util.h
index 458994d40f..16ef25b523 100644
--- a/src/libudev/time-util.h
+++ b/src/libudev/time-util.h
@@ -26,33 +26,39 @@ typedef uint64_t nsec_t;
#define USEC_FMT "%" PRIu64
+#include "macro.h"
+
typedef struct dual_timestamp {
usec_t realtime;
usec_t monotonic;
} dual_timestamp;
+#define USEC_INFINITY ((usec_t) -1)
+#define NSEC_INFINITY ((nsec_t) -1)
+
#define MSEC_PER_SEC 1000ULL
-#define USEC_PER_SEC 1000000ULL
-#define USEC_PER_MSEC 1000ULL
-#define NSEC_PER_SEC 1000000000ULL
-#define NSEC_PER_MSEC 1000000ULL
-#define NSEC_PER_USEC 1000ULL
-
-#define USEC_PER_MINUTE (60ULL*USEC_PER_SEC)
-#define NSEC_PER_MINUTE (60ULL*NSEC_PER_SEC)
-#define USEC_PER_HOUR (60ULL*USEC_PER_MINUTE)
-#define NSEC_PER_HOUR (60ULL*NSEC_PER_MINUTE)
-#define USEC_PER_DAY (24ULL*USEC_PER_HOUR)
-#define NSEC_PER_DAY (24ULL*NSEC_PER_HOUR)
-#define USEC_PER_WEEK (7ULL*USEC_PER_DAY)
-#define NSEC_PER_WEEK (7ULL*NSEC_PER_DAY)
-#define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC)
-#define NSEC_PER_MONTH (2629800ULL*NSEC_PER_SEC)
-#define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC)
-#define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC)
+#define USEC_PER_SEC ((usec_t) 1000000ULL)
+#define USEC_PER_MSEC ((usec_t) 1000ULL)
+#define NSEC_PER_SEC ((nsec_t) 1000000000ULL)
+#define NSEC_PER_MSEC ((nsec_t) 1000000ULL)
+#define NSEC_PER_USEC ((nsec_t) 1000ULL)
+
+#define USEC_PER_MINUTE ((usec_t) (60ULL*USEC_PER_SEC))
+#define NSEC_PER_MINUTE ((nsec_t) (60ULL*NSEC_PER_SEC))
+#define USEC_PER_HOUR ((usec_t) (60ULL*USEC_PER_MINUTE))
+#define NSEC_PER_HOUR ((nsec_t) (60ULL*NSEC_PER_MINUTE))
+#define USEC_PER_DAY ((usec_t) (24ULL*USEC_PER_HOUR))
+#define NSEC_PER_DAY ((nsec_t) (24ULL*NSEC_PER_HOUR))
+#define USEC_PER_WEEK ((usec_t) (7ULL*USEC_PER_DAY))
+#define NSEC_PER_WEEK ((nsec_t) (7ULL*NSEC_PER_DAY))
+#define USEC_PER_MONTH ((usec_t) (2629800ULL*USEC_PER_SEC))
+#define NSEC_PER_MONTH ((nsec_t) (2629800ULL*NSEC_PER_SEC))
+#define USEC_PER_YEAR ((usec_t) (31557600ULL*USEC_PER_SEC))
+#define NSEC_PER_YEAR ((nsec_t) (31557600ULL*NSEC_PER_SEC))
#define FORMAT_TIMESPAN_MAX 64
usec_t now(clockid_t clock);
-usec_t timespec_load(const struct timespec *ts);
+
+usec_t timespec_load(const struct timespec *ts) _pure_;
char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy);
diff --git a/src/udev/dev-setup.c b/src/udev/dev-setup.c
index 50a187fda9..1a565d5470 100644
--- a/src/udev/dev-setup.c
+++ b/src/udev/dev-setup.c
@@ -50,7 +50,7 @@ static int symlink_and_label(const char *old_path, const char *new_path) {
return r;
}
-void dev_setup(const char *prefix) {
+int dev_setup(const char *prefix) {
const char *j, *k;
static const char symlinks[] =
@@ -64,21 +64,21 @@ void dev_setup(const char *prefix) {
if (j[0] == '-') {
j++;
- if (access(j, F_OK))
+ if (access(j, F_OK) < 0)
continue;
}
if (prefix) {
- char *linkname;
+ _cleanup_free_ char *link_name = NULL;
- if (asprintf(&linkname, "%s/%s", prefix, k) < 0) {
- log_oom();
- break;
- }
+ link_name = strjoin(prefix, "/", k, NULL);
+ if (!link_name)
+ return -ENOMEM;
- symlink_and_label(j, linkname);
- free(linkname);
+ symlink_and_label(j, link_name);
} else
symlink_and_label(j, k);
}
+
+ return 0;
}
diff --git a/src/udev/dev-setup.h b/src/udev/dev-setup.h
index 320c0b30ba..d41b6eefba 100644
--- a/src/udev/dev-setup.h
+++ b/src/udev/dev-setup.h
@@ -21,4 +21,4 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-void dev_setup(const char *pathprefix);
+int dev_setup(const char *pathprefix);