Skip to content

Commit

Permalink
Clear enum attr value for GET api (sonic-net#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Jan 14, 2018
1 parent f081ec8 commit 36752e1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion meta/sai_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ sai_status_t meta_generic_validation_set(
sai_status_t meta_generic_validation_get(
_In_ const sai_object_meta_key_t& meta_key,
_In_ const uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
_In_ sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

Expand Down Expand Up @@ -2210,6 +2210,24 @@ sai_status_t meta_generic_validation_get(
}
}

/*
* When GET api is performed, later on same methods serialize/deserialize
* are used for create/set/get apis. User may not clear input attributes
* buffer (since it is in/out for example for lists) and in case of
* values that are validated like "enum" it will try to find best
* match for enum, and if not found, it will print warning message.
*
* In this place we can clear user buffer, so when it will go to
* serialize method it will pick first enum on the list.
*
* For primitive attributes we could just set entire attribute value to zero.
*/

if (md.isenum)
{
attr_list[i].value.s32 = 0;
}

switch (md.attrvaluetype)
{
case SAI_ATTR_VALUE_TYPE_BOOL:
Expand Down

0 comments on commit 36752e1

Please sign in to comment.