Skip to content

Commit

Permalink
Revert hwinfo count change (sonic-net#2383)
Browse files Browse the repository at this point in the history
What I did
Revert change from sonic-net#2367 which increases count associated with SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO by 1, as well as the memset.

Why I did it
Original intention of this change was to accommodate sairedis behaviour when copying null-terminated string; original behaviour is that the null-terminator would not be copied and so receiver of the hwinfo (PAI) would see non-null terminated string.

Reverting this change so that old behaviour is maintained and PAI driver is responsible for not relying on string to be null terminated.
  • Loading branch information
andywongarista authored Jul 26, 2022
1 parent 6565b50 commit dc88d55
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions orchagent/saihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,10 @@ sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy)
SWSS_LOG_ERROR( "hwinfo string attribute is too long." );
return SAI_STATUS_FAILURE;
}
memset(hwinfo, 0, HWINFO_MAX_SIZE + 1);
strncpy(hwinfo, phy->hwinfo.c_str(), phy->hwinfo.length());

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

Expand Down

0 comments on commit dc88d55

Please sign in to comment.