time-util: add and use USEC/NSEC_INFINIY
This commit is contained in:
parent
cf347234ae
commit
3a43da2832
|
@ -41,7 +41,7 @@ void cgroup_context_init(CGroupContext *c) {
|
|||
c->blockio_weight = (unsigned long) -1;
|
||||
c->startup_blockio_weight = (unsigned long) -1;
|
||||
|
||||
c->cpu_quota_per_sec_usec = (usec_t) -1;
|
||||
c->cpu_quota_per_sec_usec = USEC_INFINITY;
|
||||
}
|
||||
|
||||
void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a) {
|
||||
|
@ -311,7 +311,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
|
|||
if (r < 0)
|
||||
log_warning("Failed to set cpu.cfs_period_us on %s: %s", path, strerror(-r));
|
||||
|
||||
if (c->cpu_quota_per_sec_usec != (usec_t) -1) {
|
||||
if (c->cpu_quota_per_sec_usec != USEC_INFINITY) {
|
||||
sprintf(buf, USEC_FMT "\n", c->cpu_quota_per_sec_usec * CGROUP_CPU_QUOTA_PERIOD_USEC / USEC_PER_SEC);
|
||||
r = cg_set_attribute("cpu", path, "cpu.cfs_quota_us", buf);
|
||||
} else
|
||||
|
@ -447,7 +447,7 @@ CGroupControllerMask cgroup_context_get_mask(CGroupContext *c) {
|
|||
if (c->cpu_accounting ||
|
||||
c->cpu_shares != (unsigned long) -1 ||
|
||||
c->startup_cpu_shares != (unsigned long) -1 ||
|
||||
c->cpu_quota_per_sec_usec != (usec_t) -1)
|
||||
c->cpu_quota_per_sec_usec != USEC_INFINITY)
|
||||
mask |= CGROUP_CPUACCT | CGROUP_CPU;
|
||||
|
||||
if (c->blockio_accounting ||
|
||||
|
|
|
@ -300,7 +300,7 @@ static int property_get_timer_slack_nsec(
|
|||
assert(reply);
|
||||
assert(c);
|
||||
|
||||
if (c->timer_slack_nsec != (nsec_t) -1)
|
||||
if (c->timer_slack_nsec != NSEC_INFINITY)
|
||||
u = (uint64_t) c->timer_slack_nsec;
|
||||
else
|
||||
u = (uint64_t) prctl(PR_GET_TIMERSLACK);
|
||||
|
|
|
@ -333,7 +333,7 @@ static int setup_input(const ExecContext *context, int socket_fd, bool apply_tty
|
|||
i == EXEC_INPUT_TTY_FAIL,
|
||||
i == EXEC_INPUT_TTY_FORCE,
|
||||
false,
|
||||
(usec_t) -1);
|
||||
USEC_INFINITY);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
|
@ -1464,7 +1464,7 @@ int exec_spawn(ExecCommand *command,
|
|||
goto fail_child;
|
||||
}
|
||||
|
||||
if (context->timer_slack_nsec != (nsec_t) -1)
|
||||
if (context->timer_slack_nsec != NSEC_INFINITY)
|
||||
if (prctl(PR_SET_TIMERSLACK, context->timer_slack_nsec) < 0) {
|
||||
err = -errno;
|
||||
r = EXIT_TIMERSLACK;
|
||||
|
@ -1833,7 +1833,7 @@ void exec_context_init(ExecContext *c) {
|
|||
c->syslog_priority = LOG_DAEMON|LOG_INFO;
|
||||
c->syslog_level_prefix = true;
|
||||
c->ignore_sigpipe = true;
|
||||
c->timer_slack_nsec = (nsec_t) -1;
|
||||
c->timer_slack_nsec = NSEC_INFINITY;
|
||||
c->personality = 0xffffffffUL;
|
||||
c->runtime_directory_mode = 0755;
|
||||
}
|
||||
|
@ -2177,7 +2177,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
|
|||
fputs("\n", f);
|
||||
}
|
||||
|
||||
if (c->timer_slack_nsec != (nsec_t) -1)
|
||||
if (c->timer_slack_nsec != NSEC_INFINITY)
|
||||
fprintf(f, "%sTimerSlackNSec: "NSEC_FMT "\n", prefix, c->timer_slack_nsec);
|
||||
|
||||
fprintf(f,
|
||||
|
|
|
@ -2510,7 +2510,7 @@ int config_parse_cpu_quota(
|
|||
assert(rvalue);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
c->cpu_quota_per_sec_usec = (usec_t) -1;
|
||||
c->cpu_quota_per_sec_usec = USEC_INFINITY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ static usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
|
|||
static char **arg_default_environment = NULL;
|
||||
static struct rlimit *arg_default_rlimit[_RLIMIT_MAX] = {};
|
||||
static uint64_t arg_capability_bounding_set_drop = 0;
|
||||
static nsec_t arg_timer_slack_nsec = (nsec_t) -1;
|
||||
static nsec_t arg_timer_slack_nsec = NSEC_INFINITY;
|
||||
static usec_t arg_default_timer_accuracy_usec = 1 * USEC_PER_MINUTE;
|
||||
static Set* arg_syscall_archs = NULL;
|
||||
static FILE* arg_serialization = NULL;
|
||||
|
@ -1604,7 +1604,7 @@ int main(int argc, char *argv[]) {
|
|||
if (arg_running_as == SYSTEMD_SYSTEM && arg_runtime_watchdog > 0)
|
||||
watchdog_set_timeout(&arg_runtime_watchdog);
|
||||
|
||||
if (arg_timer_slack_nsec != (nsec_t) -1)
|
||||
if (arg_timer_slack_nsec != NSEC_INFINITY)
|
||||
if (prctl(PR_SET_TIMERSLACK, arg_timer_slack_nsec) < 0)
|
||||
log_error("Failed to adjust timer slack: %m");
|
||||
|
||||
|
|
|
@ -1875,7 +1875,7 @@ int manager_loop(Manager *m) {
|
|||
if (wait_usec <= 0)
|
||||
wait_usec = 1;
|
||||
} else
|
||||
wait_usec = (usec_t) -1;
|
||||
wait_usec = USEC_INFINITY;
|
||||
|
||||
r = sd_event_run(m->event, wait_usec);
|
||||
if (r < 0) {
|
||||
|
|
|
@ -46,8 +46,8 @@ static void timer_init(Unit *u) {
|
|||
assert(u);
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
t->next_elapse_monotonic_or_boottime = (usec_t) -1;
|
||||
t->next_elapse_realtime = (usec_t) -1;
|
||||
t->next_elapse_monotonic_or_boottime = USEC_INFINITY;
|
||||
t->next_elapse_realtime = USEC_INFINITY;
|
||||
t->accuracy_usec = u->manager->default_timer_accuracy_usec;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ static bool press_any_key(void) {
|
|||
printf("-- Press any key to proceed --");
|
||||
fflush(stdout);
|
||||
|
||||
read_one_char(stdin, &k, (usec_t) -1, &need_nl);
|
||||
read_one_char(stdin, &k, USEC_INFINITY, &need_nl);
|
||||
|
||||
if (need_nl)
|
||||
putchar('\n');
|
||||
|
|
|
@ -89,15 +89,15 @@ static void patch_realtime(
|
|||
assert(realtime);
|
||||
|
||||
x = timespec_load(&st->st_ctim);
|
||||
if (x > 0 && x != (usec_t) -1 && x < *realtime)
|
||||
if (x > 0 && x != USEC_INFINITY && x < *realtime)
|
||||
*realtime = x;
|
||||
|
||||
x = timespec_load(&st->st_atim);
|
||||
if (x > 0 && x != (usec_t) -1 && x < *realtime)
|
||||
if (x > 0 && x != USEC_INFINITY && x < *realtime)
|
||||
*realtime = x;
|
||||
|
||||
x = timespec_load(&st->st_mtim);
|
||||
if (x > 0 && x != (usec_t) -1 && x < *realtime)
|
||||
if (x > 0 && x != USEC_INFINITY && x < *realtime)
|
||||
*realtime = x;
|
||||
|
||||
/* Let's read the original creation time, if possible. Ideally
|
||||
|
|
|
@ -65,7 +65,7 @@ int main(int argc, char *argv[]) {
|
|||
"STATUS=Processing requests...");
|
||||
|
||||
for (;;) {
|
||||
usec_t t = (usec_t) -1, n;
|
||||
usec_t t = USEC_INFINITY, n;
|
||||
|
||||
r = sd_event_get_state(server.event);
|
||||
if (r < 0)
|
||||
|
|
|
@ -1265,7 +1265,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
|
|||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
r = sd_bus_message_append(m, "v", "t", (usec_t) -1);
|
||||
r = sd_bus_message_append(m, "v", "t", USEC_INFINITY);
|
||||
|
||||
} else if (endswith(eq, "%")) {
|
||||
double percent;
|
||||
|
|
|
@ -2646,7 +2646,7 @@ static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
|
|||
struct pollfd p[2] = {};
|
||||
int r, e, n;
|
||||
struct timespec ts;
|
||||
usec_t m = (usec_t) -1;
|
||||
usec_t m = USEC_INFINITY;
|
||||
|
||||
assert(bus);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ static void server(sd_bus *b, size_t *result) {
|
|||
assert_se(r >= 0);
|
||||
|
||||
if (r == 0)
|
||||
assert_se(sd_bus_wait(b, (usec_t) -1) >= 0);
|
||||
assert_se(sd_bus_wait(b, USEC_INFINITY) >= 0);
|
||||
if (!m)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -407,9 +407,9 @@ _public_ int sd_event_new(sd_event** ret) {
|
|||
|
||||
e->n_ref = 1;
|
||||
e->signal_fd = e->watchdog_fd = e->epoll_fd = e->realtime.fd = e->boottime.fd = e->monotonic.fd = e->realtime_alarm.fd = e->boottime_alarm.fd = -1;
|
||||
e->realtime.next = e->boottime.next = e->monotonic.next = e->realtime_alarm.next = e->boottime_alarm.next = (usec_t) -1;
|
||||
e->realtime.next = e->boottime.next = e->monotonic.next = e->realtime_alarm.next = e->boottime_alarm.next = USEC_INFINITY;
|
||||
e->original_pid = getpid();
|
||||
e->perturb = (usec_t) -1;
|
||||
e->perturb = USEC_INFINITY;
|
||||
|
||||
assert_se(sigemptyset(&e->sigset) == 0);
|
||||
|
||||
|
@ -796,7 +796,7 @@ static void initialize_perturb(sd_event *e) {
|
|||
bit. Here, we calculate a perturbation usec offset from the
|
||||
boot ID. */
|
||||
|
||||
if (_likely_(e->perturb != (usec_t) -1))
|
||||
if (_likely_(e->perturb != USEC_INFINITY))
|
||||
return;
|
||||
|
||||
if (sd_id128_get_boot(&bootid) >= 0)
|
||||
|
@ -1751,7 +1751,7 @@ static int event_arm_timer(
|
|||
if (d->fd < 0)
|
||||
return 0;
|
||||
|
||||
if (d->next == (usec_t) -1)
|
||||
if (d->next == USEC_INFINITY)
|
||||
return 0;
|
||||
|
||||
/* disarm */
|
||||
|
@ -1759,7 +1759,7 @@ static int event_arm_timer(
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
d->next = (usec_t) -1;
|
||||
d->next = USEC_INFINITY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1827,7 +1827,7 @@ static int flush_timer(sd_event *e, int fd, uint32_t events, usec_t *next) {
|
|||
return -EIO;
|
||||
|
||||
if (next)
|
||||
*next = (usec_t) -1;
|
||||
*next = USEC_INFINITY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ static usec_t calc_elapse(uint64_t usec) {
|
|||
static int rtnl_poll(sd_rtnl *rtnl, bool need_more, uint64_t timeout_usec) {
|
||||
struct pollfd p[1] = {};
|
||||
struct timespec ts;
|
||||
usec_t m = (usec_t) -1;
|
||||
usec_t m = USEC_INFINITY;
|
||||
int r, e;
|
||||
|
||||
assert(rtnl);
|
||||
|
|
|
@ -1032,7 +1032,7 @@ static int show_journal(FILE *f,
|
|||
if (!(flags & OUTPUT_FOLLOW))
|
||||
break;
|
||||
|
||||
r = sd_journal_wait(j, (usec_t) -1);
|
||||
r = sd_journal_wait(j, USEC_INFINITY);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ int polkit_agent_open(void) {
|
|||
log_error("Failed to fork TTY ask password agent: %s", strerror(-r));
|
||||
else
|
||||
/* Wait until the agent closes the fd */
|
||||
fd_wait_for_event(pipe_fd[0], POLLHUP, (usec_t) -1);
|
||||
fd_wait_for_event(pipe_fd[0], POLLHUP, USEC_INFINITY);
|
||||
|
||||
safe_close(pipe_fd[0]);
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) {
|
|||
int64_t delta;
|
||||
assert(ts);
|
||||
|
||||
if (u == (usec_t) -1) {
|
||||
ts->realtime = ts->monotonic = (usec_t) -1;
|
||||
if (u == USEC_INFINITY) {
|
||||
ts->realtime = ts->monotonic = USEC_INFINITY;
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,8 @@ dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u) {
|
|||
int64_t delta;
|
||||
assert(ts);
|
||||
|
||||
if (u == (usec_t) -1) {
|
||||
ts->realtime = ts->monotonic = (usec_t) -1;
|
||||
if (u == USEC_INFINITY) {
|
||||
ts->realtime = ts->monotonic = USEC_INFINITY;
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
@ -98,10 +98,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 +
|
||||
|
@ -111,7 +111,7 @@ usec_t timespec_load(const struct timespec *ts) {
|
|||
struct timespec *timespec_store(struct timespec *ts, usec_t u) {
|
||||
assert(ts);
|
||||
|
||||
if (u == (usec_t) -1) {
|
||||
if (u == USEC_INFINITY) {
|
||||
ts->tv_sec = (time_t) -1;
|
||||
ts->tv_nsec = (long) -1;
|
||||
return ts;
|
||||
|
@ -128,10 +128,10 @@ usec_t timeval_load(const struct timeval *tv) {
|
|||
|
||||
if (tv->tv_sec == (time_t) -1 &&
|
||||
tv->tv_usec == (suseconds_t) -1)
|
||||
return (usec_t) -1;
|
||||
return USEC_INFINITY;
|
||||
|
||||
if ((usec_t) tv->tv_sec > (UINT64_MAX - tv->tv_usec) / USEC_PER_SEC)
|
||||
return (usec_t) -1;
|
||||
return USEC_INFINITY;
|
||||
|
||||
return
|
||||
(usec_t) tv->tv_sec * USEC_PER_SEC +
|
||||
|
@ -141,7 +141,7 @@ usec_t timeval_load(const struct timeval *tv) {
|
|||
struct timeval *timeval_store(struct timeval *tv, usec_t u) {
|
||||
assert(tv);
|
||||
|
||||
if (u == (usec_t) -1) {
|
||||
if (u == USEC_INFINITY) {
|
||||
tv->tv_sec = (time_t) -1;
|
||||
tv->tv_usec = (suseconds_t) -1;
|
||||
} else {
|
||||
|
@ -159,7 +159,7 @@ char *format_timestamp(char *buf, size_t l, usec_t t) {
|
|||
assert(buf);
|
||||
assert(l > 0);
|
||||
|
||||
if (t <= 0 || t == (usec_t) -1)
|
||||
if (t <= 0 || t == USEC_INFINITY)
|
||||
return NULL;
|
||||
|
||||
sec = (time_t) (t / USEC_PER_SEC);
|
||||
|
@ -177,7 +177,7 @@ char *format_timestamp_us(char *buf, size_t l, usec_t t) {
|
|||
assert(buf);
|
||||
assert(l > 0);
|
||||
|
||||
if (t <= 0 || t == (usec_t) -1)
|
||||
if (t <= 0 || t == USEC_INFINITY)
|
||||
return NULL;
|
||||
|
||||
sec = (time_t) (t / USEC_PER_SEC);
|
||||
|
@ -198,7 +198,7 @@ char *format_timestamp_relative(char *buf, size_t l, usec_t t) {
|
|||
|
||||
n = now(CLOCK_REALTIME);
|
||||
|
||||
if (t <= 0 || (t == (usec_t) -1))
|
||||
if (t <= 0 || (t == USEC_INFINITY))
|
||||
return NULL;
|
||||
|
||||
if (n > t) {
|
||||
|
@ -279,7 +279,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) {
|
||||
|
|
|
@ -37,25 +37,28 @@ typedef struct dual_timestamp {
|
|||
usec_t monotonic;
|
||||
} dual_timestamp;
|
||||
|
||||
#define MSEC_PER_SEC ((usec_t) 1000ULL)
|
||||
#define USEC_INFINITY ((usec_t) -1)
|
||||
#define NSEC_INFINITY ((nsec_t) -1)
|
||||
|
||||
#define MSEC_PER_SEC 1000ULL
|
||||
#define USEC_PER_SEC ((usec_t) 1000000ULL)
|
||||
#define USEC_PER_MSEC ((usec_t) 1000ULL)
|
||||
#define NSEC_PER_SEC ((usec_t) 1000000000ULL)
|
||||
#define NSEC_PER_MSEC ((usec_t) 1000000ULL)
|
||||
#define NSEC_PER_USEC ((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 ((usec_t) (60ULL*NSEC_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 ((usec_t) (60ULL*NSEC_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 ((usec_t) (24ULL*NSEC_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 ((usec_t) (7ULL*NSEC_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 ((usec_t) (2629800ULL*NSEC_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 ((usec_t) (31557600ULL*NSEC_PER_SEC))
|
||||
#define NSEC_PER_YEAR ((nsec_t) (31557600ULL*NSEC_PER_SEC))
|
||||
|
||||
#define FORMAT_TIMESTAMP_MAX ((4*4+1)+11+9+4+1) /* weekdays can be unicode */
|
||||
#define FORMAT_TIMESTAMP_WIDTH 28 /* when outputting, assume this width */
|
||||
|
@ -71,8 +74,8 @@ dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u);
|
|||
dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u);
|
||||
|
||||
static inline bool dual_timestamp_is_set(dual_timestamp *ts) {
|
||||
return ((ts->realtime > 0 && ts->realtime != (usec_t) -1) ||
|
||||
(ts->monotonic > 0 && ts->monotonic != (usec_t) -1));
|
||||
return ((ts->realtime > 0 && ts->realtime != USEC_INFINITY) ||
|
||||
(ts->monotonic > 0 && ts->monotonic != USEC_INFINITY));
|
||||
}
|
||||
|
||||
usec_t timespec_load(const struct timespec *ts) _pure_;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "log.h"
|
||||
|
||||
static int watchdog_fd = -1;
|
||||
static usec_t watchdog_timeout = (usec_t) -1;
|
||||
static usec_t watchdog_timeout = USEC_INFINITY;
|
||||
|
||||
static int update_timeout(void) {
|
||||
int r;
|
||||
|
@ -37,7 +37,7 @@ static int update_timeout(void) {
|
|||
if (watchdog_fd < 0)
|
||||
return 0;
|
||||
|
||||
if (watchdog_timeout == (usec_t) -1)
|
||||
if (watchdog_timeout == USEC_INFINITY)
|
||||
return 0;
|
||||
else if (watchdog_timeout == 0) {
|
||||
int flags;
|
||||
|
@ -104,7 +104,7 @@ int watchdog_set_timeout(usec_t *usec) {
|
|||
|
||||
/* If we didn't open the watchdog yet and didn't get any
|
||||
* explicit timeout value set, don't do anything */
|
||||
if (watchdog_fd < 0 && watchdog_timeout == (usec_t) -1)
|
||||
if (watchdog_fd < 0 && watchdog_timeout == USEC_INFINITY)
|
||||
return 0;
|
||||
|
||||
if (watchdog_fd < 0)
|
||||
|
|
|
@ -1142,7 +1142,7 @@ static usec_t calc_next_elapse(dual_timestamp *nw, dual_timestamp *next) {
|
|||
assert(nw);
|
||||
assert(next);
|
||||
|
||||
if (next->monotonic != (usec_t) -1 && next->monotonic > 0) {
|
||||
if (next->monotonic != USEC_INFINITY && next->monotonic > 0) {
|
||||
usec_t converted;
|
||||
|
||||
if (next->monotonic > nw->monotonic)
|
||||
|
@ -1150,7 +1150,7 @@ static usec_t calc_next_elapse(dual_timestamp *nw, dual_timestamp *next) {
|
|||
else
|
||||
converted = nw->realtime - (nw->monotonic - next->monotonic);
|
||||
|
||||
if (next->realtime != (usec_t) -1 && next->realtime > 0)
|
||||
if (next->realtime != USEC_INFINITY && next->realtime > 0)
|
||||
next_elapse = MIN(converted, next->realtime);
|
||||
else
|
||||
next_elapse = converted;
|
||||
|
|
|
@ -343,7 +343,7 @@ static int parse_password(const char *filename, char **wall) {
|
|||
_cleanup_free_ char *password = NULL;
|
||||
|
||||
if (arg_console) {
|
||||
tty_fd = acquire_terminal("/dev/console", false, false, false, (usec_t) -1);
|
||||
tty_fd = acquire_terminal("/dev/console", false, false, false, USEC_INFINITY);
|
||||
if (tty_fd < 0)
|
||||
return tty_fd;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue