From c6f76af11695e2690d6bb84e854505120bd26b8f Mon Sep 17 00:00:00 2001 From: huangxin Date: Tue, 7 Feb 2023 09:28:23 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E9=94=99=E8=AF=AF=E7=A0=81=E6=9C=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=97=B6=E8=BF=94=E5=9B=9EERR=5FUNKNOW?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/libs/misc/err.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/srcs/libs/misc/err.c b/srcs/libs/misc/err.c index e7bba06..143d137 100644 --- a/srcs/libs/misc/err.c +++ b/srcs/libs/misc/err.c @@ -2,6 +2,7 @@ // Created by xajhuang on 2022/12/5. // #include +#include "misc.h" #define MAX_DESC_LENGTH (256) #define GENERATE_STRING(STRING, no, desc) {#STRING, desc}, @@ -11,13 +12,22 @@ static const char *g_enumStrVal[][MAX_DESC_LENGTH] = { }; const char *getErrorEnumNameString(int errCode) { + if (errCode >= ARRAY_SIZE(g_enumStrVal) || errCode < 0) { + return g_enumStrVal[ARRAY_SIZE(g_enumStrVal) - 1][0]; + } return g_enumStrVal[errCode][0]; } const char *getErrorEnumDesc(int errCode) { + if (errCode >= ARRAY_SIZE(g_enumStrVal) || errCode < 0) { + return g_enumStrVal[ARRAY_SIZE(g_enumStrVal) - 1][0]; + } return g_enumStrVal[errCode][0]; } const char *getErrorEnumDescripty(int errCode) { + if (errCode >= ARRAY_SIZE(g_enumStrVal) || errCode < 0) { + return g_enumStrVal[ARRAY_SIZE(g_enumStrVal) - 1][1]; + } return g_enumStrVal[errCode][1]; }