summaryrefslogtreecommitdiff
path: root/src/basic/time-util.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-10-18 16:15:09 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-10-18 16:30:37 +0200
commit14ce0c25c28ba58e80084e28b4f23884199900e4 (patch)
treeafee4f156a2c23049eab9701ee14d36d39709b0b /src/basic/time-util.h
parentb996f7e41abeb5ece7c5f27958e0f08a1edff3ba (diff)
downloadsystemd-14ce0c25c28ba58e80084e28b4f23884199900e4.tar.gz
timedatectl: stop using xstrftime
When using strftime in arbitrary locales, we cannot really say how big the buffer should be. Let's make the buffer "large", which will work fine pretty much always, and just print n/a if the timestamp does not fit. strftime returns 0 if the buffer is too small and a NUL-terminated string otherwise, so we can drop the size specifications in string formatting. $ export LANG=fa_IR.UTF-8 $ date چهارشنبه ۱۸ اكتبر ۱۷، ساعت ۱۰:۵۴:۲۴ (+0330) $ timedatectl Assertion 'xstrftime: a[] must be big enough' failed at ../src/timedate/timedatectl.c:105, function print_status_info(). Aborting. now: $ timedatectl Local time: چهارشنبه 2017-10-18 16:29:40 CEST Universal time: چهارشنبه 2017-10-18 14:29:40 UTC RTC time: چهارشنبه 2017-10-18 14:29:40 … https://bugzilla.redhat.com/show_bug.cgi?id=1503452
Diffstat (limited to 'src/basic/time-util.h')
-rw-r--r--src/basic/time-util.h4
1 files changed, 0 insertions, 4 deletions
diff --git a/src/basic/time-util.h b/src/basic/time-util.h
index 3b7f0e99c0..73f7e40066 100644
--- a/src/basic/time-util.h
+++ b/src/basic/time-util.h
@@ -148,10 +148,6 @@ clockid_t clock_boottime_or_monotonic(void);
usec_t usec_shift_clock(usec_t, clockid_t from, clockid_t to);
-#define xstrftime(buf, fmt, tm) \
- assert_message_se(strftime(buf, ELEMENTSOF(buf), fmt, tm) > 0, \
- "xstrftime: " #buf "[] must be big enough")
-
int get_timezone(char **timezone);
time_t mktime_or_timegm(struct tm *tm, bool utc);