Blame SOURCES/0006-nl_msec2str-fix.patch

4c8f2e
From 4ea4090788fbd0cdfb9e4c1cf2f8c96842132cb1 Mon Sep 17 00:00:00 2001
4c8f2e
From: Joe Damato <ice799@gmail.com>
4c8f2e
Date: Thu, 18 Jul 2013 22:35:45 -0700
4c8f2e
Subject: [PATCH 1/2] Handle the case where nl_msec2str is passed 0 msecs
4c8f2e
4c8f2e
(cherry picked from commit b3fb89f445108677d405c62865b25aeea209d10a)
4c8f2e
---
4c8f2e
 lib/utils.c | 5 +++++
4c8f2e
 1 file changed, 5 insertions(+)
4c8f2e
4c8f2e
diff --git a/lib/utils.c b/lib/utils.c
4c8f2e
index d7f6724..e04a7b7 100644
4c8f2e
--- a/lib/utils.c
4c8f2e
+++ b/lib/utils.c
4c8f2e
@@ -552,6 +552,11 @@ char * nl_msec2str(uint64_t msec, char *buf, size_t len)
4c8f2e
 #undef  _SPLIT
4c8f2e
 	split[4] = msec;
4c8f2e
 
4c8f2e
+	if (msec == 0) {
4c8f2e
+		snprintf(buf, len, "0msec");
4c8f2e
+		return buf_orig;
4c8f2e
+	}
4c8f2e
+
4c8f2e
 	for (i = 0; i < ARRAY_SIZE(split) && len; i++) {
4c8f2e
 		int l;
4c8f2e
 		if (split[i] == 0)
4c8f2e
-- 
4c8f2e
1.8.5.3
4c8f2e
4c8f2e
4c8f2e
From 58c7f957ca301c3ca65a3788ecb7412b32469ae1 Mon Sep 17 00:00:00 2001
4c8f2e
From: Thomas Haller <thaller@redhat.com>
4c8f2e
Date: Wed, 19 Feb 2014 19:22:13 +0100
4c8f2e
Subject: [PATCH 2/2] utils: fix nl_msec2str() which always returned '0msec'
4c8f2e
 for whole second durations
4c8f2e
4c8f2e
If the duration was without subsecond part, the function always returned
4c8f2e
'0msec', instead of giving the time in days, hours, minutes or seconds.
4c8f2e
4c8f2e
Regression introduced by commit b3fb89f445108677d405c62865b25aeea209d10a.
4c8f2e
4c8f2e
Signed-off-by: Thomas Haller <thaller@redhat.com>
4c8f2e
Acked-by: Thomas Graf <tgraf@suug.ch>
4c8f2e
(cherry picked from commit 3fb0aae0bc37eafe868d28f0f12ee8803d7ad266)
4c8f2e
---
4c8f2e
 lib/utils.c | 10 +++++-----
4c8f2e
 1 file changed, 5 insertions(+), 5 deletions(-)
4c8f2e
4c8f2e
diff --git a/lib/utils.c b/lib/utils.c
4c8f2e
index e04a7b7..44350c3 100644
4c8f2e
--- a/lib/utils.c
4c8f2e
+++ b/lib/utils.c
4c8f2e
@@ -544,6 +544,11 @@ char * nl_msec2str(uint64_t msec, char *buf, size_t len)
4c8f2e
 	static const char *units[5] = {"d", "h", "m", "s", "msec"};
4c8f2e
 	char * const buf_orig = buf;
4c8f2e
 
4c8f2e
+	if (msec == 0) {
4c8f2e
+		snprintf(buf, len, "0msec");
4c8f2e
+		return buf_orig;
4c8f2e
+	}
4c8f2e
+
4c8f2e
 #define _SPLIT(idx, unit) if ((split[idx] = msec / unit)) msec %= unit
4c8f2e
 	_SPLIT(0, 86400000);	/* days */
4c8f2e
 	_SPLIT(1, 3600000);	/* hours */
4c8f2e
@@ -552,11 +557,6 @@ char * nl_msec2str(uint64_t msec, char *buf, size_t len)
4c8f2e
 #undef  _SPLIT
4c8f2e
 	split[4] = msec;
4c8f2e
 
4c8f2e
-	if (msec == 0) {
4c8f2e
-		snprintf(buf, len, "0msec");
4c8f2e
-		return buf_orig;
4c8f2e
-	}
4c8f2e
-
4c8f2e
 	for (i = 0; i < ARRAY_SIZE(split) && len; i++) {
4c8f2e
 		int l;
4c8f2e
 		if (split[i] == 0)
4c8f2e
-- 
4c8f2e
1.8.5.3
4c8f2e