ID: 28 - 'lib/ipmi_delloem.c' - clean up the code

ipmi_macinfo_drac_virtual_mac - simplify - Return immediately if NicNum doesn't
meet expectations.
This commit is contained in:
Zdenek Styblik 2013-07-07 11:54:36 +00:00
parent eb65a625a2
commit f1f2cbb18b

View File

@ -1539,45 +1539,38 @@ ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum)
uint8_t input_length=0; uint8_t input_length=0;
uint8_t j; uint8_t j;
uint8_t i; uint8_t i;
if (0xff == NicNum || IDRAC_NIC_NUMBER == NicNum) { if (NicNum != 0xff && NicNum != IDRAC_NIC_NUMBER) {
UseVirtualMacAddress = 0; return 0;
input_length = 0; }
msg_data[input_length++] = 1; /*Get*/ UseVirtualMacAddress = 0;
input_length = 0;
msg_data[input_length++] = 1; /*Get*/
req.msg.netfn = DELL_OEM_NETFN; req.msg.netfn = DELL_OEM_NETFN;
req.msg.lun = 0; req.msg.lun = 0;
req.msg.cmd = GET_IDRAC_VIRTUAL_MAC; req.msg.cmd = GET_IDRAC_VIRTUAL_MAC;
req.msg.data = msg_data; req.msg.data = msg_data;
req.msg.data_len = input_length; req.msg.data_len = input_length;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) { if (rsp == NULL) {
return -1; return -1;
} }
if (rsp->ccode > 0) { if (rsp->ccode > 0) {
return -1; return -1;
} }
if ((IMC_IDRAC_12G_MODULAR == IMC_Type) if ((IMC_IDRAC_12G_MODULAR == IMC_Type)
|| (IMC_IDRAC_12G_MONOLITHIC== IMC_Type) ) { || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type) ) {
/* Get the Chasiss Assigned MAC Addresss for 12g Only */ /* Get the Chasiss Assigned MAC Addresss for 12g Only */
memcpy(VirtualMacAddress, ((rsp->data) + 1), MACADDRESSLENGH); memcpy(VirtualMacAddress, ((rsp->data) + 1), MACADDRESSLENGH);
for (i = 0; i < MACADDRESSLENGH; i++) { for (i = 0; i < MACADDRESSLENGH; i++) {
if (VirtualMacAddress[i] != 0) { if (VirtualMacAddress[i] != 0) {
UseVirtualMacAddress = 1; UseVirtualMacAddress = 1;
}
} }
/* Get the Server Assigned MAC Addresss for 12g Only */ }
if (!UseVirtualMacAddress) { /* Get the Server Assigned MAC Addresss for 12g Only */
memcpy(VirtualMacAddress, ((rsp->data) + 1 + MACADDRESSLENGH), if (!UseVirtualMacAddress) {
MACADDRESSLENGH); memcpy(VirtualMacAddress, ((rsp->data) + 1 + MACADDRESSLENGH),
for (i = 0; i < MACADDRESSLENGH; i++) {
if (VirtualMacAddress[i] != 0) {
UseVirtualMacAddress = 1;
}
}
}
} else {
memcpy(VirtualMacAddress, ((rsp->data) + VIRTUAL_MAC_OFFSET),
MACADDRESSLENGH); MACADDRESSLENGH);
for (i = 0; i < MACADDRESSLENGH; i++) { for (i = 0; i < MACADDRESSLENGH; i++) {
if (VirtualMacAddress[i] != 0) { if (VirtualMacAddress[i] != 0) {
@ -1585,30 +1578,38 @@ ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum)
} }
} }
} }
if (UseVirtualMacAddress == 0) { } else {
return -1; memcpy(VirtualMacAddress, ((rsp->data) + VIRTUAL_MAC_OFFSET),
MACADDRESSLENGH);
for (i = 0; i < MACADDRESSLENGH; i++) {
if (VirtualMacAddress[i] != 0) {
UseVirtualMacAddress = 1;
}
} }
if (IMC_IDRAC_10G == IMC_Type) {
printf("\nDRAC MAC Address ");
} else if ((IMC_IDRAC_11G_MODULAR == IMC_Type)
|| (IMC_IDRAC_11G_MONOLITHIC== IMC_Type)) {
printf("\niDRAC6 MAC Address ");
} else if ((IMC_IDRAC_12G_MODULAR == IMC_Type)
|| (IMC_IDRAC_12G_MONOLITHIC== IMC_Type)) {
printf("\niDRAC7 MAC Address ");
} else if ((IMC_MASER_LITE_BMC== IMC_Type)
|| (IMC_MASER_LITE_NU== IMC_Type)) {
printf("\nBMC MAC Address ");
} else {
printf("\niDRAC6 MAC Address ");
}
for (j = 0; j < 5; j++) {
printf("%02x:", VirtualMacAddress[j]);
}
printf("%02x", VirtualMacAddress[j]);
printf("\n");
} }
if (UseVirtualMacAddress == 0) {
return -1;
}
if (IMC_IDRAC_10G == IMC_Type) {
printf("\nDRAC MAC Address ");
} else if ((IMC_IDRAC_11G_MODULAR == IMC_Type)
|| (IMC_IDRAC_11G_MONOLITHIC== IMC_Type)) {
printf("\niDRAC6 MAC Address ");
} else if ((IMC_IDRAC_12G_MODULAR == IMC_Type)
|| (IMC_IDRAC_12G_MONOLITHIC== IMC_Type)) {
printf("\niDRAC7 MAC Address ");
} else if ((IMC_MASER_LITE_BMC== IMC_Type)
|| (IMC_MASER_LITE_NU== IMC_Type)) {
printf("\nBMC MAC Address ");
} else {
printf("\niDRAC6 MAC Address ");
}
for (j = 0; j < 5; j++) {
printf("%02x:", VirtualMacAddress[j]);
}
printf("%02x", VirtualMacAddress[j]);
printf("\n");
return 0; return 0;
} }
/* /*