From: VMware, Inc <> Date: Thu, 17 Jun 2010 22:13:02 +0000 (-0700) Subject: Minor code review fixes for previous ctime_r changes. X-Git-Tag: 2010.06.16-268169~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fa142b52f638b7c83a905046342dc8b941b99d7;p=thirdparty%2Fopen-vm-tools.git Minor code review fixes for previous ctime_r changes. 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 --- diff --git a/open-vm-tools/lib/misc/timeutil.c b/open-vm-tools/lib/misc/timeutil.c index 238673cf6..6f4c70bb3 100644 --- a/open-vm-tools/lib/misc/timeutil.c +++ b/open-vm-tools/lib/misc/timeutil.c @@ -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