1. 增加错误日志打印
This commit is contained in:
parent
47ad1bc8d3
commit
ec1531f32a
@ -2,6 +2,10 @@
|
||||
|
||||
#include <HBit.h>
|
||||
|
||||
#ifndef LogD
|
||||
#define LogD(...)
|
||||
#endif
|
||||
|
||||
static void InitHBit(HBitType *data) {
|
||||
if ((data[0] & kHBitInitFlag) == 0) {
|
||||
return;
|
||||
@ -31,6 +35,7 @@ static HBitType GetBit(const HBitType *data, HBitIndexType index) {
|
||||
|
||||
void HBitSet(HBitType *data, HBitIndexType index, HBitType value) {
|
||||
if (index >= GetBitLen(data)) {
|
||||
LogD("error index[%d], len[%d]", index, GetBitLen(data));
|
||||
return ;
|
||||
}
|
||||
|
||||
@ -40,6 +45,7 @@ void HBitSet(HBitType *data, HBitIndexType index, HBitType value) {
|
||||
|
||||
HBitType HBitGet(const HBitType *data, HBitIndexType index) {
|
||||
if (index >= GetBitLen(data)) {
|
||||
LogD("error index[%d], len[%d]", index, GetBitLen(data));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,11 @@
|
||||
#include <HByteStack.h>
|
||||
|
||||
|
||||
#ifndef LogD
|
||||
#define LogD(...)
|
||||
#endif
|
||||
|
||||
|
||||
static void InitStack(HByteType *stackData) {
|
||||
if ((stackData[0] & kHByteStackNeedInit) == 0) {
|
||||
return;
|
||||
@ -48,6 +53,7 @@ static HByteLenType GetStackLen(const HByteType *stackData) {
|
||||
InitStack((HByteType *)stackData);
|
||||
|
||||
if ((base->flag & kHByteStackFlagAllMask) == 0) {
|
||||
LogD("error flag[%d]", base->flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -59,6 +65,7 @@ static HByteLenType GetStackUseLen(const HByteType *stackData) {
|
||||
InitStack((HByteType *)stackData);
|
||||
|
||||
if ((base->flag & kHByteStackFlagAllMask) == 0) {
|
||||
LogD("error flag[%d]", base->flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -70,6 +77,7 @@ static void SetStackUseLen(HByteType *stackData, HByteLenType len) {
|
||||
InitStack((HByteType *)stackData);
|
||||
|
||||
if ((base->flag & kHByteStackFlagAllMask) == 0) {
|
||||
LogD("error flag[%d]", base->flag);
|
||||
return ;
|
||||
}
|
||||
|
||||
@ -137,6 +145,7 @@ HByteLenType HByteStackGetUseLen(const HByteType *stackData) {
|
||||
|
||||
void HByteStackSetUseLen(HByteType *stackData, HByteLenType pos) {
|
||||
if (pos >= HByteStackGetUseLen(stackData)) {
|
||||
LogD("error pos[%d], useLen[%d]", pos, HByteStackGetUseLen(stackData));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
|
||||
#include <HTimer.h>
|
||||
|
||||
#ifndef LogD
|
||||
#define LogD(...)
|
||||
#endif
|
||||
|
||||
static uint32_t (*GetCurrentMs)(void);
|
||||
|
||||
@ -22,6 +25,7 @@ static struct Timer timers[HTIMER_MAX];
|
||||
|
||||
static void CallTimer(int16_t index) {
|
||||
if (index < 0 || index >= HTIMER_MAX) {
|
||||
LogD("error index[%d]", index);
|
||||
return ;
|
||||
}
|
||||
|
||||
@ -37,10 +41,12 @@ static void CallTimer(int16_t index) {
|
||||
|
||||
static int16_t AddTimerData(uint32_t duration, HTimerCallType call, eHTimerFlags flags) {
|
||||
if (!GetCurrentMs) {
|
||||
LogD("GetCurrentMs not init");
|
||||
return HTIMER_INVALID;
|
||||
}
|
||||
|
||||
if ((duration & ~CHECK_VALUE) != 0) {
|
||||
LogD("duration overflow, duration[%d]", duration);
|
||||
return HTIMER_INVALID;
|
||||
}
|
||||
|
||||
@ -57,6 +63,7 @@ static int16_t AddTimerData(uint32_t duration, HTimerCallType call, eHTimerFlags
|
||||
return i;
|
||||
}
|
||||
|
||||
LogD("timers full, duration[%d], flags[%d]", duration, flags);
|
||||
return HTIMER_INVALID;
|
||||
}
|
||||
|
||||
@ -114,6 +121,7 @@ int16_t HTimerAdd(uint32_t ms, HTimerCallType call, eHTimerFlags flags) {
|
||||
|
||||
void HTimerRemove(int16_t index) {
|
||||
if (index < 0 || index >= HTIMER_MAX) {
|
||||
LogD("error index[%d]", index);
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
@ -3,8 +3,14 @@
|
||||
#include <HVector.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef LogD
|
||||
#define LogD(...)
|
||||
#endif
|
||||
|
||||
|
||||
static void InitVector(HVectorType *vector) {
|
||||
if (vector == NULL) {
|
||||
LogD("vector is NULL");
|
||||
return ;
|
||||
}
|
||||
|
||||
@ -96,6 +102,7 @@ static HVectorLenType GetVectorByteUseLen(const HVectorType *vector) {
|
||||
|
||||
static void *GetVectorDataBytePtr(HVectorType *vector, HVectorLenType bytePos) {
|
||||
if (bytePos >= GetVectorByteLen(vector)) {
|
||||
LogD("bytePos[%d] error, len[%d]", bytePos, GetVectorByteLen(vector));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -120,6 +127,7 @@ static void SetVectorUseLen(HVectorType *vector, HVectorLenType len) {
|
||||
uint8_t HVectorAddData(HVectorType *vector, HVectorDataType data) {
|
||||
HVectorLenType len = GetVectorUseLen(vector);
|
||||
if (len >= GetVectorLen(vector)) {
|
||||
LogD("len[%d] error, len[%d]", len, GetVectorLen(vector));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user