Skip to content

Commit 4865e5e

Browse files
authored
[CASESession] refactoring and improving testability of Sigma1 sending and handling, and Sigma2 Sending (#36679)
* Removing networking bits from CASESession ParseSigma1 and creating EncodeSigma1 * integrating comments * Refactoring HandleSigma1_and_SendSigma2 and functions called within it * Adding Encrypted2 datalen check * renaming variables * Making Parsing and Encoding methods protected * Converting TLV tags to enum class * Making structs protected and making Unit Test inherit CASESession * integrating comments * Integrating comments in TestCASESession * integrate comments on CASESession * Integrating more comments * Using a Variant for the NextStep logic in HandleSigma1, to either send a Sigma message or a status report * fixing clang-tidy error * more comments * comments integration
1 parent 017e8b5 commit 4865e5e

File tree

4 files changed

+850
-376
lines changed

4 files changed

+850
-376
lines changed

src/lib/support/CodeUtils.h

+27
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,33 @@
156156
} \
157157
} while (false)
158158

159+
/**
160+
* @def ReturnErrorVariantOnFailure(expr)
161+
*
162+
* @brief
163+
* This is for use when the calling function returns a Variant type. It returns a CHIP_ERROR variant with the corresponding error
164+
* code if the expression returns an error.
165+
*
166+
* Example usage:
167+
*
168+
* @code
169+
* ReturnErrorVariantOnFailure(NextStep, ParseSigma1(tlvReader, parsedSigma1));
170+
* @endcode
171+
*
172+
* @param[in] variantType The Variant type that the calling function returns.
173+
* @param[in] expr An expression to be tested.
174+
175+
*/
176+
#define ReturnErrorVariantOnFailure(variantType, expr) \
177+
do \
178+
{ \
179+
auto __err = (expr); \
180+
if (!::chip::ChipError::IsSuccess(__err)) \
181+
{ \
182+
return variantType::Create<CHIP_ERROR>(__err); \
183+
} \
184+
} while (false)
185+
159186
/**
160187
* @def ReturnLogErrorOnFailure(expr)
161188
*

0 commit comments

Comments
 (0)