Fix printf if time_t is long long
On some platforms, time_t has recently switched from "long" to "long long" [1]. For these platforms it is necessary to use "%lld" as printf format specifier because the ABI differs between "long" and "long long". I found no way for creating something similar to PRId64 for time_t. No idea how to determine whether it's "long" or "long long". So I cast everything to "long long" instead. [1] https://git.musl-libc.org/cgit/musl/commit/?id=38143339646a4ccce8afe298c34467767c899f51 Signed-off-by: Christian Eggers <ceggers@arri.de>master
parent
6eb9898f61
commit
7de73fefc3
|
@ -197,8 +197,8 @@ static int do_set(clockid_t clkid, int cmdc, char *cmdv[])
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
pr_notice("set clock time to %ld.%09ld or %s",
|
pr_notice("set clock time to %lld.%09ld or %s",
|
||||||
ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
|
(long long)ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
|
||||||
}
|
}
|
||||||
|
|
||||||
return args_to_eat;
|
return args_to_eat;
|
||||||
|
@ -215,8 +215,8 @@ static int do_get(clockid_t clkid, int cmdc, char *cmdv[])
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
pr_notice("clock time is %ld.%09lu or %s",
|
pr_notice("clock time is %lld.%09lu or %s",
|
||||||
ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
|
(long long)ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get operation does not require any arguments */
|
/* get operation does not require any arguments */
|
||||||
|
|
8
print.c
8
print.c
|
@ -73,16 +73,16 @@ void print(int level, char const *format, ...)
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
f = level >= LOG_NOTICE ? stdout : stderr;
|
f = level >= LOG_NOTICE ? stdout : stderr;
|
||||||
fprintf(f, "%s[%ld.%03ld]: %s%s%s\n",
|
fprintf(f, "%s[%lld.%03ld]: %s%s%s\n",
|
||||||
progname ? progname : "",
|
progname ? progname : "",
|
||||||
ts.tv_sec, ts.tv_nsec / 1000000,
|
(long long)ts.tv_sec, ts.tv_nsec / 1000000,
|
||||||
message_tag ? message_tag : "", message_tag ? " " : "",
|
message_tag ? message_tag : "", message_tag ? " " : "",
|
||||||
buf);
|
buf);
|
||||||
fflush(f);
|
fflush(f);
|
||||||
}
|
}
|
||||||
if (use_syslog) {
|
if (use_syslog) {
|
||||||
syslog(level, "[%ld.%03ld] %s%s%s",
|
syslog(level, "[%lld.%03ld] %s%s%s",
|
||||||
ts.tv_sec, ts.tv_nsec / 1000000,
|
(long long)ts.tv_sec, ts.tv_nsec / 1000000,
|
||||||
message_tag ? message_tag : "", message_tag ? " " : "",
|
message_tag ? message_tag : "", message_tag ? " " : "",
|
||||||
buf);
|
buf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ static void unicast_client_set_renewal(struct port *p,
|
||||||
long duration)
|
long duration)
|
||||||
{
|
{
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
long tmo;
|
time_t tmo;
|
||||||
|
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &now)) {
|
if (clock_gettime(CLOCK_MONOTONIC, &now)) {
|
||||||
pr_err("clock_gettime failed: %m");
|
pr_err("clock_gettime failed: %m");
|
||||||
|
@ -217,7 +217,7 @@ static void unicast_client_set_renewal(struct port *p,
|
||||||
tmo = now.tv_sec + duration;
|
tmo = now.tv_sec + duration;
|
||||||
if (!master->renewal_tmo || tmo < master->renewal_tmo) {
|
if (!master->renewal_tmo || tmo < master->renewal_tmo) {
|
||||||
master->renewal_tmo = tmo;
|
master->renewal_tmo = tmo;
|
||||||
pr_debug("port %d: renewal timeout at %ld", portnum(p), tmo);
|
pr_debug("port %d: renewal timeout at %lld", portnum(p), (long long)tmo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,9 +209,9 @@ static void unicast_service_extend(struct unicast_client_address *client,
|
||||||
tmo = now.tv_sec + req->durationField;
|
tmo = now.tv_sec + req->durationField;
|
||||||
if (tmo > client->grant_tmo) {
|
if (tmo > client->grant_tmo) {
|
||||||
client->grant_tmo = tmo;
|
client->grant_tmo = tmo;
|
||||||
pr_debug("%s grant of 0x%x extended to %ld",
|
pr_debug("%s grant of 0x%x extended to %lld",
|
||||||
pid2str(&client->portIdentity),
|
pid2str(&client->portIdentity),
|
||||||
client->message_types, tmo);
|
client->message_types, (long long)tmo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,8 +226,8 @@ static int unicast_service_rearm_timer(struct port *p)
|
||||||
interval = pqueue_peek(p->unicast_service->queue);
|
interval = pqueue_peek(p->unicast_service->queue);
|
||||||
if (interval) {
|
if (interval) {
|
||||||
tmo.it_value = interval->tmo;
|
tmo.it_value = interval->tmo;
|
||||||
pr_debug("arming timer tmo={%ld,%ld}",
|
pr_debug("arming timer tmo={%lld,%ld}",
|
||||||
interval->tmo.tv_sec, interval->tmo.tv_nsec);
|
(long long)interval->tmo.tv_sec, interval->tmo.tv_nsec);
|
||||||
} else {
|
} else {
|
||||||
pr_debug("stopping unicast service timer");
|
pr_debug("stopping unicast service timer");
|
||||||
}
|
}
|
||||||
|
@ -499,8 +499,8 @@ int unicast_service_timer(struct port *p)
|
||||||
|
|
||||||
while ((interval = pqueue_peek(p->unicast_service->queue)) != NULL) {
|
while ((interval = pqueue_peek(p->unicast_service->queue)) != NULL) {
|
||||||
|
|
||||||
pr_debug("peek i={2^%d} tmo={%ld,%ld}", interval->log_period,
|
pr_debug("peek i={2^%d} tmo={%lld,%ld}", interval->log_period,
|
||||||
interval->tmo.tv_sec, interval->tmo.tv_nsec);
|
(long long)interval->tmo.tv_sec, interval->tmo.tv_nsec);
|
||||||
|
|
||||||
if (timespec_compare(&now, &interval->tmo) > 0) {
|
if (timespec_compare(&now, &interval->tmo) > 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -519,8 +519,8 @@ int unicast_service_timer(struct port *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
interval_increment(interval);
|
interval_increment(interval);
|
||||||
pr_debug("next i={2^%d} tmo={%ld,%ld}", interval->log_period,
|
pr_debug("next i={2^%d} tmo={%lld,%ld}", interval->log_period,
|
||||||
interval->tmo.tv_sec, interval->tmo.tv_nsec);
|
(long long)interval->tmo.tv_sec, interval->tmo.tv_nsec);
|
||||||
pqueue_insert(p->unicast_service->queue, interval);
|
pqueue_insert(p->unicast_service->queue, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue