mirror of
https://github.com/ipmitool/ipmitool.git
synced 2026-06-28 16:21:35 +00:00
Refactoring. Improve code reuse ratio.
Add ARRAY_SIZE() macro. Use the new macro in all places where array size is calculated by means of sizeof(array)/sizeof(array[0]). Fix minor bugs and warnings in the affected code. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
@@ -898,6 +898,7 @@ fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru,
|
||||
uint8_t * fru_data;
|
||||
uint32_t fru_len, i;
|
||||
uint8_t tmp[2];
|
||||
size_t chassis_type;
|
||||
|
||||
fru_len = 0;
|
||||
|
||||
@@ -931,10 +932,10 @@ fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru,
|
||||
*/
|
||||
i = 2;
|
||||
|
||||
printf(" Chassis Type : %s\n",
|
||||
chassis_type_desc[fru_data[i] >
|
||||
(sizeof(chassis_type_desc)/sizeof(chassis_type_desc[0])) - 1 ?
|
||||
2 : fru_data[i]]);
|
||||
chassis_type = (fru_data[i] > ARRAY_SIZE(chassis_type_desc) - 1)
|
||||
? 2
|
||||
: fru_data[i];
|
||||
printf(" Chassis Type : %s\n", chassis_type_desc[chassis_type]);
|
||||
|
||||
i++;
|
||||
|
||||
|
||||
@@ -1027,9 +1027,7 @@ static void lanp_print_usage(int cmd)
|
||||
printf("\n available parameters:\n");
|
||||
/* 'save' shall use 'write' filter, since it outputs a block
|
||||
* of 'set's */
|
||||
ipmi_cfgp_usage(lan_cfgp,
|
||||
sizeof(lan_cfgp)/sizeof(lan_cfgp[0]),
|
||||
cmd != LANP_CMD_PRINT);
|
||||
ipmi_cfgp_usage(lan_cfgp, ARRAY_SIZE(lan_cfgp), cmd != LANP_CMD_PRINT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,8 +1159,8 @@ ipmi_lan6_main(struct ipmi_intf *intf, int argc, char **argv)
|
||||
*/
|
||||
|
||||
ipmi_cfgp_init(&ctx, lan_cfgp,
|
||||
sizeof(lan_cfgp)/sizeof(lan_cfgp[0]), "lan6 set nolock",
|
||||
lanp_ip6_cfgp, &lp);
|
||||
ARRAY_SIZE(lan_cfgp), "lan6 set nolock",
|
||||
lanp_ip6_cfgp, &lp);
|
||||
|
||||
ret = ipmi_cfgp_parse_sel(&ctx, argc, (const char **)argv, &sel);
|
||||
if (ret == -1) {
|
||||
|
||||
Reference in New Issue
Block a user