[systemd-commits] 2 commits - man/sd_event_new.xml src/timedate
Thomas H.P. Andersen
phomes at kemper.freedesktop.org
Mon Apr 14 10:23:33 PDT 2014
man/sd_event_new.xml | 4 +-
src/timedate/timedatectl.c | 79 +++++++++++++++++++++++----------------------
2 files changed, 44 insertions(+), 39 deletions(-)
New commits:
commit 2667cc25896a15f82f9f1583e80d416beb1316e1
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date: Mon Apr 14 19:16:56 2014 +0200
timedatectl: avoid using uninitialized var
sec is not set if have_time is false so avoid using it. have_time
was introduced in 9ff09bcb86fb125768667aca9bc0b10b1745370a but only
the first uses for sec were covered
Found with scan-build
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 0664f69..a8769e4 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -148,51 +148,56 @@ static void print_status_info(const StatusInfo *i) {
} else
printf(" RTC time: %s\n", "n/a");
- zero(tm);
- assert_se(strftime(a, sizeof(a), "%Z, %z", localtime_r(&sec, &tm)) > 0);
- char_array_0(a);
+ if (have_time) {
+ zero(tm);
+ assert_se(strftime(a, sizeof(a), "%Z, %z", localtime_r(&sec, &tm)) > 0);
+ char_array_0(a);
+ }
+
printf(" Time zone: %s (%s)\n"
" NTP enabled: %s\n"
"NTP synchronized: %s\n"
" RTC in local TZ: %s\n",
- strna(i->timezone), a,
+ strna(i->timezone), have_time ? a : "n/a",
i->ntp_capable ? yes_no(i->ntp_enabled) : "n/a",
yes_no(i->ntp_synced),
yes_no(i->rtc_local));
- r = time_get_dst(sec, "/etc/localtime",
- &tc, &zc, &is_dstc,
- &tn, &dn, &zn, &is_dstn);
- if (r < 0)
- printf(" DST active: %s\n", "n/a");
- else if (have_time) {
- printf(" DST active: %s\n", yes_no(is_dstc));
-
- t = tc - 1;
- zero(tm);
- assert_se(strftime(a, sizeof(a), "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&t, &tm)) > 0);
- char_array_0(a);
-
- 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 %s at\n"
- " %s\n"
- " %s\n",
- is_dstc ? "began" : "ended", a, b);
-
- t = tn - 1;
- zero(tm);
- assert_se(strftime(a, sizeof(a), "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&t, &tm)) > 0);
- char_array_0(a);
-
- 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 %s (the clock jumps %s) at\n"
- " %s\n"
- " %s\n",
- is_dstn ? "begins" : "ends", jump_str(dn, s, sizeof(s)), a, b);
+ if (have_time) {
+ r = time_get_dst(sec, "/etc/localtime",
+ &tc, &zc, &is_dstc,
+ &tn, &dn, &zn, &is_dstn);
+ if (r < 0)
+ printf(" DST active: %s\n", "n/a");
+ else {
+ printf(" DST active: %s\n", yes_no(is_dstc));
+
+ t = tc - 1;
+ zero(tm);
+ assert_se(strftime(a, sizeof(a), "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&t, &tm)) > 0);
+ char_array_0(a);
+
+ 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 %s at\n"
+ " %s\n"
+ " %s\n",
+ is_dstc ? "began" : "ended", a, b);
+
+ t = tn - 1;
+ zero(tm);
+ assert_se(strftime(a, sizeof(a), "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&t, &tm)) > 0);
+ char_array_0(a);
+
+ 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 %s (the clock jumps %s) at\n"
+ " %s\n"
+ " %s\n",
+ is_dstn ? "begins" : "ends", jump_str(dn, s, sizeof(s)), a, b);
+ }
} else
printf(" DST active: %s\n", yes_no(is_dstc));
commit a6ad1458e8baf913e9ee377c52863b927d7a2638
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date: Mon Apr 14 19:12:45 2014 +0200
man: fix typos in sd_event_new
diff --git a/man/sd_event_new.xml b/man/sd_event_new.xml
index 1fe1820..6545cde 100644
--- a/man/sd_event_new.xml
+++ b/man/sd_event_new.xml
@@ -92,7 +92,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
to the default event loop object of the calling thread, possibly
allocating a new object if no default event loop object has been
allocated yet for the thread. After use drop the returned
- referened with <function>sd_event_unref()</function>. When the
+ reference with <function>sd_event_unref()</function>. When the
last reference is dropped the event loop is freed. If this
function is called while the object returned from a previous call
from the same thread is still referenced, the same object is
@@ -108,7 +108,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<para><function>sd_event_unref()</function> decreases the
reference counter of the specified event loop object by one. If
- the counter hits zero the event loop object is freed. Not that it
+ the counter hits zero the event loop object is freed. Note that it
is freed regardless if it is the default event loop object of a
thread or not. This means that allocating an event loop with
<function>sd_event_default()</function>, then releasing it and
More information about the systemd-commits
mailing list