summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2014-07-29 12:23:31 +0200
committerKay Sievers <kay@vrfy.org>2014-07-29 13:20:20 +0200
commit3a43da2832dc5360a638d043f469a6dcbe025582 (patch)
treee3b60e840bb087c1af7f458676e3ab6bf04ea49e /src/shared/util.c
parentcf347234ae78630dd4aad8907f027965e7fb9040 (diff)
time-util: add and use USEC/NSEC_INFINIY
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 49c17eff85..b1689e651f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1581,7 +1581,7 @@ int read_one_char(FILE *f, char *ret, usec_t t, bool *need_nl) {
if (tcsetattr(fileno(f), TCSADRAIN, &new_termios) >= 0) {
size_t k;
- if (t != (usec_t) -1) {
+ if (t != USEC_INFINITY) {
if (fd_wait_for_event(fileno(f), POLLIN, t) <= 0) {
tcsetattr(fileno(f), TCSADRAIN, &old_termios);
return -ETIMEDOUT;
@@ -1603,7 +1603,7 @@ int read_one_char(FILE *f, char *ret, usec_t t, bool *need_nl) {
}
}
- if (t != (usec_t) -1) {
+ if (t != USEC_INFINITY) {
if (fd_wait_for_event(fileno(f), POLLIN, t) <= 0)
return -ETIMEDOUT;
}
@@ -1648,7 +1648,7 @@ int ask_char(char *ret, const char *replies, const char *text, ...) {
fflush(stdout);
- r = read_one_char(stdin, &c, (usec_t) -1, &need_nl);
+ r = read_one_char(stdin, &c, USEC_INFINITY, &need_nl);
if (r < 0) {
if (r == -EBADMSG) {
@@ -1898,11 +1898,11 @@ int acquire_terminal(
* on the same tty as an untrusted user this should not be a
* problem. (Which he probably should not do anyway.) */
- if (timeout != (usec_t) -1)
+ if (timeout != USEC_INFINITY)
ts = now(CLOCK_MONOTONIC);
if (!fail && !force) {
- notify = inotify_init1(IN_CLOEXEC | (timeout != (usec_t) -1 ? IN_NONBLOCK : 0));
+ notify = inotify_init1(IN_CLOEXEC | (timeout != USEC_INFINITY ? IN_NONBLOCK : 0));
if (notify < 0) {
r = -errno;
goto fail;
@@ -1966,7 +1966,7 @@ int acquire_terminal(
ssize_t l;
struct inotify_event *e;
- if (timeout != (usec_t) -1) {
+ if (timeout != USEC_INFINITY) {
usec_t n;
n = now(CLOCK_MONOTONIC);
@@ -2148,7 +2148,7 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) {
* and expect that any error/EOF is reported
* via read() */
- fd_wait_for_event(fd, POLLIN, (usec_t) -1);
+ fd_wait_for_event(fd, POLLIN, USEC_INFINITY);
continue;
}
@@ -2183,7 +2183,7 @@ ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
* and expect that any error/EOF is reported
* via write() */
- fd_wait_for_event(fd, POLLOUT, (usec_t) -1);
+ fd_wait_for_event(fd, POLLOUT, USEC_INFINITY);
continue;
}
@@ -3428,7 +3428,7 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
return -errno;
}
- if (stamp != (usec_t) -1) {
+ if (stamp != USEC_INFINITY) {
struct timespec ts[2];
timespec_store(&ts[0], stamp);
@@ -3443,7 +3443,7 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
}
int touch(const char *path) {
- return touch_file(path, false, (usec_t) -1, (uid_t) -1, (gid_t) -1, 0);
+ return touch_file(path, false, USEC_INFINITY, (uid_t) -1, (gid_t) -1, 0);
}
char *unquote(const char *s, const char* quotes) {
@@ -3904,7 +3904,7 @@ void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
* timout. We simply rely on SIGALRM as default action
* terminating the process, and turn on alarm(). */
- if (timeout != (usec_t) -1)
+ if (timeout != USEC_INFINITY)
alarm((timeout + USEC_PER_SEC - 1) / USEC_PER_SEC);
while (!hashmap_isempty(pids)) {
@@ -4074,7 +4074,7 @@ int fd_wait_for_event(int fd, int event, usec_t t) {
struct timespec ts;
int r;
- r = ppoll(&pollfd, 1, t == (usec_t) -1 ? NULL : timespec_store(&ts, t), NULL);
+ r = ppoll(&pollfd, 1, t == USEC_INFINITY ? NULL : timespec_store(&ts, t), NULL);
if (r < 0)
return -errno;
@@ -5273,7 +5273,7 @@ int make_console_stdio(void) {
/* Make /dev/console the controlling terminal and stdin/stdout/stderr */
- fd = acquire_terminal("/dev/console", false, true, true, (usec_t) -1);
+ fd = acquire_terminal("/dev/console", false, true, true, USEC_INFINITY);
if (fd < 0) {
log_error("Failed to acquire terminal: %s", strerror(-fd));
return fd;