From dc88d55d144f3c918534894ff0303a5f7995acab Mon Sep 17 00:00:00 2001 From: andywongarista <78833093+andywongarista@users.noreply.github.com> Date: Mon, 25 Jul 2022 20:04:40 -0700 Subject: [PATCH] Revert hwinfo count change (#2383) What I did Revert change from #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. --- orchagent/saihelper.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/orchagent/saihelper.cpp b/orchagent/saihelper.cpp index ee6ce2b8021d..172b74b55961 100644 --- a/orchagent/saihelper.cpp +++ b/orchagent/saihelper.cpp @@ -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);