@@ -378,10 +378,11 @@ sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy)
378
378
SWSS_LOG_ERROR ( " hwinfo string attribute is too long." );
379
379
return SAI_STATUS_FAILURE;
380
380
}
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 ());
382
383
383
384
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 ;
385
386
attr.value .s8list .list = (int8_t *) hwinfo;
386
387
attrs.push_back (attr);
387
388
@@ -441,21 +442,21 @@ sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy)
441
442
442
443
phy->phy_oid = sai_serialize_object_id (phyOid);
443
444
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 )
447
446
{
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
+ }
459
459
}
460
460
return status;
461
461
}
462
+
0 commit comments