virTimeFieldsThenRaw will never return negative result, so I clean up
the related meaningless judgements to make it better.
Signed-off-by: James <james.wangyufei(a)huawei.com>
---
src/util/virtime.c | 23 ++++++++---------------
src/util/virtime.h | 8 ++++----
tests/virtimetest.c | 3 +--
3 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/src/util/virtime.c b/src/util/virtime.c
index 2a91ea5..a49e287 100644
--- a/src/util/virtime.c
+++ b/src/util/virtime.c
@@ -94,7 +94,8 @@ int virTimeFieldsNowRaw(struct tm *fields)
if (virTimeMillisNowRaw(&now) < 0)
return -1;
- return virTimeFieldsThenRaw(now, fields);
+ virTimeFieldsThenRaw(now, fields);
+ return 0;
}
@@ -121,9 +122,8 @@ const unsigned short int __mon_yday[2][13] = {
* Converts the timestamp @when into broken-down field format.
* Time time is always in UTC
*
- * Returns 0 on success, -1 on error with errno set
*/
-int virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
+void virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
{
/* This code is taken from GLibC under terms of LGPLv2+ */
long int days, rem, y;
@@ -171,7 +171,6 @@ int virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
days -= ip[y];
fields->tm_mon = y;
fields->tm_mday = days + 1;
- return 0;
}
@@ -209,8 +208,7 @@ int virTimeStringThenRaw(unsigned long long when, char *buf)
{
struct tm fields;
- if (virTimeFieldsThenRaw(when, &fields) < 0)
- return -1;
+ virTimeFieldsThenRaw(when, &fields);
fields.tm_year += 1900;
fields.tm_mon += 1;
@@ -264,7 +262,8 @@ int virTimeFieldsNow(struct tm *fields)
if (virTimeMillisNow(&now) < 0)
return -1;
- return virTimeFieldsThen(now, fields);
+ virTimeFieldsThen(now, fields);
+ return 0;
}
@@ -276,16 +275,10 @@ int virTimeFieldsNow(struct tm *fields)
* Converts the timestamp @when into broken-down field format.
* Time time is always in UTC
*
- * Returns 0 on success, -1 on error with error reported
*/
-int virTimeFieldsThen(unsigned long long when, struct tm *fields)
+void virTimeFieldsThen(unsigned long long when, struct tm *fields)
{
- if (virTimeFieldsThenRaw(when, fields) < 0) {
- virReportSystemError(errno, "%s",
- _("Unable to break out time format"));
- return -1;
- }
- return 0;
+ virTimeFieldsThenRaw(when, fields);
}
diff --git a/src/util/virtime.h b/src/util/virtime.h
index 25332db..f9432da 100644
--- a/src/util/virtime.h
+++ b/src/util/virtime.h
@@ -43,8 +43,8 @@ int virTimeMillisNowRaw(unsigned long long *now)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virTimeFieldsNowRaw(struct tm *fields)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
-int virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
- ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+void virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
+ ATTRIBUTE_NONNULL(2);
int virTimeStringNowRaw(char *buf)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virTimeStringThenRaw(unsigned long long when, char *buf)
@@ -57,8 +57,8 @@ int virTimeMillisNow(unsigned long long *now)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virTimeFieldsNow(struct tm *fields)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
-int virTimeFieldsThen(unsigned long long when, struct tm *fields)
- ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+void virTimeFieldsThen(unsigned long long when, struct tm *fields)
+ ATTRIBUTE_NONNULL(2);
char *virTimeStringNow(void);
char *virTimeStringThen(unsigned long long when);
diff --git a/tests/virtimetest.c b/tests/virtimetest.c
index 859bd13..64bf19b 100644
--- a/tests/virtimetest.c
+++ b/tests/virtimetest.c
@@ -44,8 +44,7 @@ static int testTimeFields(const void *args)
const struct testTimeFieldsData *data = args;
struct tm actual;
- if (virTimeFieldsThen(data->when, &actual) < 0)
- return -1;
+ virTimeFieldsThen(data->when, &actual);
#define COMPARE(field) \
do { \
--
1.7.12.4