From cbc62cda0852ccf25824b3b37007ff471842292b Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 13 Jun 2023 13:36:48 -0700 Subject: [PATCH] [cli] update `OutputEidCacheEntry()` (#9171) This commit updates `OutputEidCacheEntry()` and how it converts cache entry state to string. --- src/cli/cli.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 144d08547..765ff9550 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -2544,23 +2544,23 @@ template <> otError Interpreter::Process(Arg aArgs[]) { return mDns. #endif #if OPENTHREAD_FTD -const char *EidCacheStateToString(otCacheEntryState aState) -{ - static const char *const kStateStrings[4] = { - "cache", - "snoop", - "query", - "retry", - }; - - return Interpreter::Stringify(aState, kStateStrings); -} - void Interpreter::OutputEidCacheEntry(const otCacheEntryInfo &aEntry) { + static const char *const kStateStrings[] = { + "cache", // (0) OT_CACHE_ENTRY_STATE_CACHED + "snoop", // (1) OT_CACHE_ENTRY_STATE_SNOOPED + "query", // (2) OT_CACHE_ENTRY_STATE_QUERY + "retry", // (3) OT_CACHE_ENTRY_STATE_RETRY_QUERY + }; + + static_assert(0 == OT_CACHE_ENTRY_STATE_CACHED, "OT_CACHE_ENTRY_STATE_CACHED value is incorrect"); + static_assert(1 == OT_CACHE_ENTRY_STATE_SNOOPED, "OT_CACHE_ENTRY_STATE_SNOOPED value is incorrect"); + static_assert(2 == OT_CACHE_ENTRY_STATE_QUERY, "OT_CACHE_ENTRY_STATE_QUERY value is incorrect"); + static_assert(3 == OT_CACHE_ENTRY_STATE_RETRY_QUERY, "OT_CACHE_ENTRY_STATE_RETRY_QUERY value is incorrect"); + OutputIp6Address(aEntry.mTarget); OutputFormat(" %04x", aEntry.mRloc16); - OutputFormat(" %s", EidCacheStateToString(aEntry.mState)); + OutputFormat(" %s", Stringify(aEntry.mState, kStateStrings)); OutputFormat(" canEvict=%d", aEntry.mCanEvict); if (aEntry.mState == OT_CACHE_ENTRY_STATE_CACHED)