Fixed time_t conversion bug for 64-bit OS

.
This commit is contained in:
Jordan Hargrave 2006-05-23 20:41:08 +00:00
parent ce3636894d
commit 4ab522ab29
2 changed files with 6 additions and 4 deletions

View File

@ -730,6 +730,7 @@ ipmi_pef_get_status(struct ipmi_intf * intf)
struct ipmi_rq req; struct ipmi_rq req;
struct pef_cfgparm_selector psel; struct pef_cfgparm_selector psel;
char tbuf[40]; char tbuf[40];
uint32_t timei;
time_t ts; time_t ts;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
@ -741,11 +742,12 @@ ipmi_pef_get_status(struct ipmi_intf * intf)
"Last S/W processed ID"); "Last S/W processed ID");
return; return;
} }
memcpy(&timei, rsp->data, sizeof(timei));
#if WORDS_BIGENDIAN #if WORDS_BIGENDIAN
ts = (time_t)(rsp->data[0]<<24 + rsp->data[1]<<16 + rsp->data[2]<<8 + rsp->data[3]); timei = BSWAP_32(timei);
#else
ts = (time_t)(*(long *)rsp->data);
#endif #endif
ts = (time_t)timei;
strftime(tbuf, sizeof(tbuf), "%m/%d/%Y %H:%M:%S", localtime(&ts)); strftime(tbuf, sizeof(tbuf), "%m/%d/%Y %H:%M:%S", localtime(&ts));
ipmi_pef_print_str("Last SEL addition", tbuf); ipmi_pef_print_str("Last SEL addition", tbuf);

View File

@ -1501,7 +1501,7 @@ ipmi_sel_get_time(struct ipmi_intf * intf)
memcpy(&timei, rsp->data, 4); memcpy(&timei, rsp->data, 4);
#if WORDS_BIGENDIAN #if WORDS_BIGENDIAN
timei = BSWAP_32(time); timei = BSWAP_32(timei);
#endif #endif
time = (time_t)timei; time = (time_t)timei;