ID: 3568976 - 'sel set time' behaviour is inconsistent

Commit fixes inconsistent behaviour of 'sel set time' command. This was caused
by random init values of tm structures.
Also, the state of DST should be looked up now.
This commit is contained in:
Zdenek Styblik 2012-09-28 17:50:56 +00:00
parent 700ee7d27d
commit 23a5477d6e

View File

@ -2461,7 +2461,7 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
struct tm tm; struct tm tm = {0};
time_t t; time_t t;
uint32_t timei; uint32_t timei;
const char * time_format = "%m/%d/%Y %H:%M:%S"; const char * time_format = "%m/%d/%Y %H:%M:%S";
@ -2480,6 +2480,7 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string)
lprintf(LOG_ERR, "Specified time could not be parsed"); lprintf(LOG_ERR, "Specified time could not be parsed");
return -1; return -1;
} }
tm.tm_isdst = (-1); /* look up DST information */
t = mktime(&tm); t = mktime(&tm);
if (t < 0) { if (t < 0) {
lprintf(LOG_ERR, "Specified time could not be parsed"); lprintf(LOG_ERR, "Specified time could not be parsed");
@ -2489,13 +2490,14 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string)
{ {
//modify UTC time to local time expressed in number of seconds from 1/1/70 0:0:0 1970 GMT //modify UTC time to local time expressed in number of seconds from 1/1/70 0:0:0 1970 GMT
struct tm * tm_tmp; struct tm * tm_tmp = {0};
int gt_year,gt_yday,gt_hour,lt_year,lt_yday,lt_hour; int gt_year,gt_yday,gt_hour,lt_year,lt_yday,lt_hour;
int delta_hour; int delta_hour;
tm_tmp=gmtime(&t); tm_tmp=gmtime(&t);
gt_year=tm_tmp->tm_year; gt_year=tm_tmp->tm_year;
gt_yday=tm_tmp->tm_yday; gt_yday=tm_tmp->tm_yday;
gt_hour=tm_tmp->tm_hour; gt_hour=tm_tmp->tm_hour;
memset(&tm_tmp, 0, sizeof(struct tm));
tm_tmp=localtime(&t); tm_tmp=localtime(&t);
lt_year=tm_tmp->tm_year; lt_year=tm_tmp->tm_year;
lt_yday=tm_tmp->tm_yday; lt_yday=tm_tmp->tm_yday;