SAI icon indicating copy to clipboard operation
SAI copied to clipboard

Saistatus.h: saistatus range macros do not handle negative statuses (Linux) well

Open yohadd opened this issue 3 years ago • 1 comments

When using saistatuses that are in range (SAI_STATUS_0 - SAI_STATUS_MAX) ,

on Linux setup (negative saistatus), the helper MACROs SAI_STATUS_IS_(x), returns False for statuses in range except for the SAI_STATUS__0).

It seems that they are not handling negative statuses well.

For example (in saistatus.h): #define SAI_STATUS_CODE(S) (-(S))

/**

  • @brief Invalid attribute value
  • Range from 0x00020000L to 0x0002FFFFL. / #define SAI_STATUS_INVALID_ATTR_VALUE_0 SAI_STATUS_CODE(0x00020000L) /*
  • @brief End of invalid attribute value range */ #define SAI_STATUS_INVALID_ATTR_VALUE_MAX SAI_STATUS_CODE(0x0002FFFFL)

/**

  • @brief Is invalid attribute value helper */ #define SAI_STATUS_IS_INVALID_ATTR_VALUE(x) (((x) & (~0xFFFF)) == SAI_STATUS_INVALID_ATTR_VALUE_0)

SAI_STATUS_IS_INVALID_ATTR_VALUE(x) will return False for all negative numbers between -0x00020001L to -0x0002FFFFL

Thanks in advance.

yohadd avatar Aug 16 '22 12:08 yohadd

this problem was already discussed here: https://github.com/opencomputeproject/SAI/pull/1235 but not addressed

kcudnik avatar Aug 22 '22 14:08 kcudnik