Skip to content

Commit b949238

Browse files
Address review comments, fix hwinfo
1 parent 9883f23 commit b949238

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

orchagent/saihelper.cpp

+17-16
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,11 @@ sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy)
378378
SWSS_LOG_ERROR( "hwinfo string attribute is too long." );
379379
return SAI_STATUS_FAILURE;
380380
}
381-
strncpy(hwinfo, phy->hwinfo.c_str(), HWINFO_MAX_SIZE);
381+
memset(hwinfo, 0, HWINFO_MAX_SIZE + 1);
382+
strncpy(hwinfo, phy->hwinfo.c_str(), phy->hwinfo.length());
382383

383384
attr.id = SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO;
384-
attr.value.s8list.count = (uint32_t) phy->hwinfo.length();
385+
attr.value.s8list.count = (uint32_t) phy->hwinfo.length() + 1;
385386
attr.value.s8list.list = (int8_t *) hwinfo;
386387
attrs.push_back(attr);
387388

@@ -441,21 +442,21 @@ sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy)
441442

442443
phy->phy_oid = sai_serialize_object_id(phyOid);
443444

444-
attr.id = SAI_SWITCH_ATTR_FIRMWARE_MAJOR_VERSION;
445-
status = sai_switch_api->get_switch_attribute(phyOid, 1, &attr);
446-
if (status == SAI_STATUS_SUCCESS)
445+
if (phy->firmware.length() != 0)
447446
{
448-
phy->firmware_major_version = string(attr.value.chardata);
449-
}
450-
else if ( status == SAI_STATUS_NOT_SUPPORTED )
451-
{
452-
phy->firmware_major_version = "N/A";
453-
status = SAI_STATUS_SUCCESS;
454-
}
455-
else
456-
{
457-
SWSS_LOG_ERROR("BOX: Failed to get firmware major version:%d rtn:%d", phy->phy_id, status);
458-
return status;
447+
attr.id = SAI_SWITCH_ATTR_FIRMWARE_MAJOR_VERSION;
448+
status = sai_switch_api->get_switch_attribute(phyOid, 1, &attr);
449+
if (status != SAI_STATUS_SUCCESS)
450+
{
451+
SWSS_LOG_ERROR("BOX: Failed to get firmware major version for hwinfo:%s, phy:%d, rtn:%d",
452+
phy->hwinfo.c_str(), phy->phy_id, status);
453+
return status;
454+
}
455+
else
456+
{
457+
phy->firmware_major_version = string(attr.value.chardata);
458+
}
459459
}
460460
return status;
461461
}
462+

0 commit comments

Comments
 (0)