Skip to content

fixes #172, Add support for editing FRU 'board mfg date' #328

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

doublechiang
Copy link
Contributor

based on discussion #172 (comment)

@@ -598,21 +598,34 @@ struct fru_picmgext_amc_link_desc_record {
/* FRU Board manufacturing date */
#define FRU_BOARD_DATE_UNSPEC 0 /* IPMI FRU Information Storage Definition
v1.0 rev 1.3, Table 11-1 */

static inline uint32_t SECS_FROM_1970_1996=820454400;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you demote it to uint32_t while moving it to global namespace?
Actually, I think it would be the best to use time_t. And it has to be const, on the contrary, inline doesn't seem to do anything here.

lib/ipmi_fru.c Outdated
ipmi_time2fru(total_secs, board_mfg_date);

checksum = 0;
/* Calculate Header Checksum */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the comment to the same level with the code, please.

uint32_t *board_mfg_date=&fru_data[3];

total_secs = ipmi_strptime("%Y-%m-%d %H:%M:%S", f_string);
ipmi_time2fru(total_secs, board_mfg_date);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a range check is required here. we don't want values that exceed 24 bits, but ipmi_strptime is capable of returning greater values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should we check the range of the total_secs?
The total_secs will be subtracted by SECS_FROM_1970_1996 and divided by 60 to get the minutes and mask down to three bytes. I think this is safe here.

checksum += fru_data[i];
}
checksum = (~checksum) + 1;
fru_data[fru_section_len - 1] = checksum;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ipmi_csum() please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it looks to me like all this FRU update code forgets to update the overall FRU checksum after modifying an area.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we update the mfg date only and we do not change any length of the records.
I don't think the common header field checksum will be changed.

@doublechiang
Copy link
Contributor Author

Please let me know if there are any changes required.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants