]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Minor code review fixes for previous ctime_r changes.
authorVMware, Inc <>
Thu, 17 Jun 2010 22:13:02 +0000 (15:13 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 17 Jun 2010 22:13:02 +0000 (15:13 -0700)
Add some newlines and comments.  Change a hard-coded size
to sizeof.  Added an assignment to force conversion to
time_t.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/misc/timeutil.c

index 238673cf6266159595cfe7da8ed381510690ac37..6f4c70bb33b835023918b8edd6d7fd00ef36eb36 100644 (file)
@@ -854,12 +854,14 @@ TimeUtil_GetTimeFormat(int64 utcTime,  // IN
 #else
    char *str;
    char buf[26];
+   time_t t = (time_t) utcTime;  // Implicit narrowing conversion on 32-bit
+
 #if defined sun
-   str = Util_SafeStrdup(ctime_r((const time_t *) &utcTime, buf, 26));
+   str = Util_SafeStrdup(ctime_r((const time_t *) &t, buf, sizeof buf));
 #else
-   str = Util_SafeStrdup(ctime_r((const time_t *) &utcTime, buf));
+   str = Util_SafeStrdup(ctime_r((const time_t *) &t, buf));
 #endif
-   str[strlen(str)-1] = '\0';
+   str[strlen(str) - 1] = '\0';  // Remove the trailing '\n'.
 
    return str;
 #endif // _WIN32