]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: virTimeFieldsThenRaw never returns negative
authorJames <james.wangyufei@huawei.com>
Fri, 25 Jul 2014 08:13:57 +0000 (16:13 +0800)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 25 Jul 2014 10:06:07 +0000 (12:06 +0200)
virTimeFieldsThenRaw will never return negative result, so I clean up
the related meaningless judgements to make it better.

Signed-off-by: James <james.wangyufei@huawei.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/libvirt_private.syms
src/util/virtime.c
src/util/virtime.h
tests/virtimetest.c

index 51504d13cdf6b14205f3fbf63b9a719054c4a125..b1fb7c944324ac61e4eaf9ef7746391ef07c278e 100644 (file)
@@ -2032,7 +2032,6 @@ virThreadPoolSendJob;
 virTimeFieldsNow;
 virTimeFieldsNowRaw;
 virTimeFieldsThen;
-virTimeFieldsThenRaw;
 virTimeLocalOffsetFromUTC;
 virTimeMillisNow;
 virTimeMillisNowRaw;
index 2a91ea5d95d76f63ecf92365339d5d836b8943c8..9fefb672a67e061b9867c800655e820730411714 100644 (file)
@@ -94,7 +94,9 @@ int virTimeFieldsNowRaw(struct tm *fields)
     if (virTimeMillisNowRaw(&now) < 0)
         return -1;
 
-    return virTimeFieldsThenRaw(now, fields);
+    virTimeFieldsThen(now, fields);
+
+    return 0;
 }
 
 
@@ -114,16 +116,15 @@ const unsigned short int __mon_yday[2][13] = {
     ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
 
 /**
- * virTimeFieldsThenRaw:
+ * virTimeFieldsThen:
  * @when: the time to convert in milliseconds
  * @fields: filled with time @when fields
  *
  * 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 virTimeFieldsThen(unsigned long long when, struct tm *fields)
 {
     /* This code is taken from GLibC under terms of LGPLv2+ */
     long int days, rem, y;
@@ -171,7 +172,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 +209,7 @@ int virTimeStringThenRaw(unsigned long long when, char *buf)
 {
     struct tm fields;
 
-    if (virTimeFieldsThenRaw(when, &fields) < 0)
-        return -1;
+    virTimeFieldsThen(when, &fields);
 
     fields.tm_year += 1900;
     fields.tm_mon += 1;
@@ -264,27 +263,7 @@ int virTimeFieldsNow(struct tm *fields)
     if (virTimeMillisNow(&now) < 0)
         return -1;
 
-    return virTimeFieldsThen(now, fields);
-}
-
-
-/**
- * virTimeFieldsThen:
- * @when: the time to convert in milliseconds
- * @fields: filled with time @when 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)
-{
-    if (virTimeFieldsThenRaw(when, fields) < 0) {
-        virReportSystemError(errno, "%s",
-                             _("Unable to break out time format"));
-        return -1;
-    }
+    virTimeFieldsThen(now, fields);
     return 0;
 }
 
index 25332dba93ab83191fecf0f70f776a17af469d58..8ebad38c7f0c3f9ea8d83e03b3e6f2010cdbd4b2 100644 (file)
     (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 5 + 1)
 /*   Yr      Mon     Day     Hour    Min     Sec     Ms  TZ  NULL */
 
+void virTimeFieldsThen(unsigned long long when, struct tm *fields)
+    ATTRIBUTE_NONNULL(2);
+
 /* These APIs are async signal safe and return -1, setting
  * errno on failure */
 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;
 int virTimeStringNowRaw(char *buf)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
 int virTimeStringThenRaw(unsigned long long when, char *buf)
@@ -57,8 +58,6 @@ 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;
 char *virTimeStringNow(void);
 char *virTimeStringThen(unsigned long long when);
 
index 859bd13fad5da3a61105302476af0e5692fa29a5..64bf19b7580a08932495ec34310812ba311b8be5 100644 (file)
@@ -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 {                                                        \