chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use initalization instead of explicit zeroing
[elogind.git]
/
src
/
timedate
/
timedatectl.c
diff --git
a/src/timedate/timedatectl.c
b/src/timedate/timedatectl.c
index e17f631566e492864aff648b76dcf99cca1a6e65..8d4e560b938239cede1fe287f7f1cb755c66611d 100644
(file)
--- a/
src/timedate/timedatectl.c
+++ b/
src/timedate/timedatectl.c
@@
-51,7
+51,7
@@
static void pager_open_if_enabled(void) {
if (arg_no_pager)
return;
if (arg_no_pager)
return;
- pager_open();
+ pager_open(
false
);
}
static void polkit_agent_open_if_enabled(void) {
}
static void polkit_agent_open_if_enabled(void) {
@@
-68,12
+68,12
@@
typedef struct StatusInfo {
const char *timezone;
bool local_rtc;
bool ntp;
const char *timezone;
bool local_rtc;
bool ntp;
+ bool can_ntp;
} StatusInfo;
static bool ntp_synced(void) {
} StatusInfo;
static bool ntp_synced(void) {
- struct timex txc;
+ struct timex txc
= {}
;
- zero(txc);
if (adjtimex(&txc) < 0)
return false;
if (adjtimex(&txc) < 0)
return false;
@@
-145,16
+145,15
@@
static void print_status_info(StatusInfo *i) {
}
zero(tm);
}
zero(tm);
- assert_se(strftime(a, sizeof(a), "%z", localtime_r(&sec, &tm)) > 0);
+ assert_se(strftime(a, sizeof(a), "%
Z, %
z", localtime_r(&sec, &tm)) > 0);
char_array_0(a);
char_array_0(a);
- printf(" Timezone: %s\n"
- " UTC offset: %s\n"
+ printf(" Timezone: %s (%s)\n"
" NTP enabled: %s\n"
"NTP synchronized: %s\n"
" RTC in local TZ: %s\n",
strna(i->timezone),
a,
" NTP enabled: %s\n"
"NTP synchronized: %s\n"
" RTC in local TZ: %s\n",
strna(i->timezone),
a,
-
yes_no(i->ntp)
,
+
i->can_ntp ? yes_no(i->ntp) : "n/a"
,
yes_no(ntp_synced()),
yes_no(i->local_rtc));
yes_no(ntp_synced()),
yes_no(i->local_rtc));
@@
-174,10
+173,10
@@
static void print_status_info(StatusInfo *i) {
zero(tm);
assert_se(strftime(b, sizeof(b), "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&tc, &tm)) > 0);
char_array_0(b);
zero(tm);
assert_se(strftime(b, sizeof(b), "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&tc, &tm)) > 0);
char_array_0(b);
- printf(" Last DST change: DST
became %s
\n"
+ printf(" Last DST change: DST
%s at
\n"
" %s\n"
" %s\n",
" %s\n"
" %s\n",
- is_dstc ? "
active" : "inactive
", a, b);
+ is_dstc ? "
began" : "ended
", a, b);
t = tn - 1;
zero(tm);
t = tn - 1;
zero(tm);
@@
-187,10
+186,10
@@
static void print_status_info(StatusInfo *i) {
zero(tm);
assert_se(strftime(b, sizeof(b), "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&tn, &tm)) > 0);
char_array_0(b);
zero(tm);
assert_se(strftime(b, sizeof(b), "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&tn, &tm)) > 0);
char_array_0(b);
- printf(" Next DST change: DST
will become %s, the clock will jump %s
\n"
+ printf(" Next DST change: DST
%s (the clock jumps %s) at
\n"
" %s\n"
" %s\n",
" %s\n"
" %s\n",
- is_dstn ? "
active" : "inactive
", jump_str(dn, s, sizeof(s)), a, b);
+ is_dstn ? "
begins" : "ends
", jump_str(dn, s, sizeof(s)), a, b);
free(zc);
free(zn);
free(zc);
free(zn);
@@
-229,6
+228,8
@@
static int status_property(const char *name, DBusMessageIter *iter, StatusInfo *
i->local_rtc = b;
else if (streq(name, "NTP"))
i->ntp = b;
i->local_rtc = b;
else if (streq(name, "NTP"))
i->ntp = b;
+ else if (streq(name, "CanNTP"))
+ i->can_ntp = b;
}
}
}
}
@@
-240,7
+241,7
@@
static int show_status(DBusConnection *bus, char **args, unsigned n) {
const char *interface = "";
int r;
DBusMessageIter iter, sub, sub2, sub3;
const char *interface = "";
int r;
DBusMessageIter iter, sub, sub2, sub3;
- StatusInfo info;
+ StatusInfo info
= {}
;
assert(args);
assert(args);
@@
-264,7
+265,6
@@
static int show_status(DBusConnection *bus, char **args, unsigned n) {
return -EIO;
}
return -EIO;
}
- zero(info);
dbus_message_iter_recurse(&iter, &sub);
while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
dbus_message_iter_recurse(&iter, &sub);
while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
@@
-426,7
+426,6
@@
static int list_timezones(DBusConnection *bus, char **args, unsigned n) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **zones = NULL;
size_t n_zones = 0;
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **zones = NULL;
size_t n_zones = 0;
- char **i;
assert(args);
assert(n == 1);
assert(args);
assert(n == 1);
@@
-488,8
+487,7
@@
static int list_timezones(DBusConnection *bus, char **args, unsigned n) {
pager_open_if_enabled();
strv_sort(zones);
pager_open_if_enabled();
strv_sort(zones);
- STRV_FOREACH(i, zones)
- puts(*i);
+ strv_print(zones);
return 0;
}
return 0;
}
@@
-552,7
+550,6
@@
static int parse_argv(int argc, char *argv[]) {
case ARG_VERSION:
puts(PACKAGE_STRING);
case ARG_VERSION:
puts(PACKAGE_STRING);
- puts(DISTRIBUTION);
puts(SYSTEMD_FEATURES);
return 0;
puts(SYSTEMD_FEATURES);
return 0;