Hi Zdenek,
I have obsreved two issues on ipmi_sdr_print_info frunction.
Timestamp data type ----Earlier it was short, due to this we get wrong time stamp when it is overflowing. Hence changed to time_t type in below patch.
If Delete/Appand SDR not supported--- Then wrong time (garbage value) stamp is shown, instead of NO time display. Hence funtionality has been changed in below patch.
Here is the patch with commit ID details.
commit 302380ea31ac15555046d505a948adc0992f349c
Author: srinivasa rao m srinivasa_mareedu@dell.com
Date: Mon Oct 24 02:06:59 2016 -0400
ipmitool SDR code dont have check for valid date to print based on 'Delete SDR command supported' and 'Partial Add SDR command supported', if 0xffffffff is taken Also 'Timestamp' data type need to change to time_t(long) because same datatye is using for gmtime(time_t) API, it has different behaviour for Linux and windows C
diff --git a/lib/ipmi_sdr.c b/lib/ipmi_sdr.c
index 2a9cbe3..aaa62d7 100644
--- a/lib/ipmi_sdr.c
+++ b/lib/ipmi_sdr.c
@@ -4217,7 +4217,7 @@ ipmi_sdr_get_info(struct ipmi_intf intf,
* returns pointer to static buffer
/
static char
-ipmi_sdr_timestamp(uint32_t stamp)
+ipmi_sdr_timestamp(time_t stamp)
{
static char tbuf[40];
time_t s = (time_t) stamp;
@@ -4240,7 +4240,7 @@ ipmi_sdr_timestamp(uint32_t stamp)
int
ipmi_sdr_print_info(struct ipmi_intf intf)
{
- uint32_t timestamp;
+ time_t timestamp;
uint16_t free_space;
struct get_sdr_repository_info_rsp sdr_repository_info;
@@ -4273,22 +4273,51 @@ ipmi_sdr_print_info(struct ipmi_intf *intf)
printf("%d bytes\n", free_space);
break;
}
-
- timestamp =
- (sdr_repository_info.most_recent_addition_timestamp[3] << 24) |
- (sdr_repository_info.most_recent_addition_timestamp[2] << 16) |
- (sdr_repository_info.most_recent_addition_timestamp[1] << 8) |
- sdr_repository_info.most_recent_addition_timestamp[0];
- printf("Most recent Addition : %s\n",
- ipmi_sdr_timestamp(timestamp));
-
- timestamp =
- (sdr_repository_info.most_recent_erase_timestamp[3] << 24) |
- (sdr_repository_info.most_recent_erase_timestamp[2] << 16) |
- (sdr_repository_info.most_recent_erase_timestamp[1] << 8) |
- sdr_repository_info.most_recent_erase_timestamp[0];
- printf("Most recent Erase : %s\n",
- ipmi_sdr_timestamp(timestamp));
+ if(sdr_repository_info.delete_sdr_supported && sdr_repository_info.partial_add_sdr_supported)
+ {
+ timestamp =
+ (sdr_repository_info.most_recent_addition_timestamp[3] << 24) |
+ (sdr_repository_info.most_recent_addition_timestamp[2] << 16) |
+ (sdr_repository_info.most_recent_addition_timestamp[1] << 8) |
+ sdr_repository_info.most_recent_addition_timestamp[0];
+ printf("Most recent Addition : %s\n",
+ ipmi_sdr_timestamp(timestamp));
+
+ timestamp =
+ (sdr_repository_info.most_recent_erase_timestamp[3] << 24) |
+ (sdr_repository_info.most_recent_erase_timestamp[2] << 16) |
+ (sdr_repository_info.most_recent_erase_timestamp[1] << 8) |
+ sdr_repository_info.most_recent_erase_timestamp[0];
+ printf("Most recent Erase : %s\n",
+ ipmi_sdr_timestamp(timestamp));
+ }
+ else if (sdr_repository_info.partial_add_sdr_supported)
+ {
+ timestamp =
+ (sdr_repository_info.most_recent_addition_timestamp[3] << 24) |
+ (sdr_repository_info.most_recent_addition_timestamp[2] << 16) |
+ (sdr_repository_info.most_recent_addition_timestamp[1] << 8) |
+ sdr_repository_info.most_recent_addition_timestamp[0];
+ printf("Most recent Addition : %s\n",
+ ipmi_sdr_timestamp(timestamp));
+ printf("Most recent Erase : NA\n");
+ }
+ else if(sdr_repository_info.delete_sdr_supported)
+ {
+ printf("Most recent Addition : NA\n");
+ timestamp =
+ (sdr_repository_info.most_recent_erase_timestamp[3] << 24) |
+ (sdr_repository_info.most_recent_erase_timestamp[2] << 16) |
+ (sdr_repository_info.most_recent_erase_timestamp[1] << 8) |
+ sdr_repository_info.most_recent_erase_timestamp[0];
+ printf("Most recent Erase : %s\n",
+ ipmi_sdr_timestamp(timestamp));
+ }
+ else
+ {
+ printf("Most recent Addition : NA\n");
+ printf("Most recent Erase : NA\n");
+ }
printf("SDR overflow : %s\n", (sdr_repository_info.overflow_flag ? "yes" : "no"));
Hello Srinivasa,
please, can you attach patch as a file?
Thank you.
Z.
Also, please, see https://sourceforge.net/p/ipmitool/wiki/Coding%20Standards/
PFA
Hi, Zdenek Styblik
Any updates on this.
Br,
MSR
Patch has been merged. Thank you.
Best regards,
Zdenek