提交 de4a0047 编写于 作者: G Ganlin Zhao

fix coverity issue CID:399957

上级 591feef4
......@@ -38,10 +38,10 @@ typedef struct SRawExprNode {
} SRawExprNode;
typedef struct SDataType {
uint8_t type;
uint8_t precision;
uint8_t scale;
int32_t bytes;
uint16_t type;
uint8_t precision;
uint8_t scale;
int32_t bytes;
} SDataType;
typedef struct SExprNode {
......
......@@ -76,6 +76,7 @@ int32_t tjsonGetSmallIntValue(const SJson* pJson, const char* pName, int16_t* pV
int32_t tjsonGetTinyIntValue(const SJson* pJson, const char* pName, int8_t* pVal);
int32_t tjsonGetUBigIntValue(const SJson* pJson, const char* pName, uint64_t* pVal);
int32_t tjsonGetUIntValue(const SJson* pJson, const char* pName, uint32_t* pVal);
int32_t tjsonGetUSmallIntValue(const SJson* pJson, const char* pName, uint16_t* pVal);
int32_t tjsonGetUTinyIntValue(const SJson* pJson, const char* pName, uint8_t* pVal);
int32_t tjsonGetBoolValue(const SJson* pJson, const char* pName, bool* pVal);
int32_t tjsonGetDoubleValue(const SJson* pJson, const char* pName, double* pVal);
......
......@@ -2972,7 +2972,7 @@ static int32_t dataTypeToJson(const void* pObj, SJson* pJson) {
static int32_t jsonToDataType(const SJson* pJson, void* pObj) {
SDataType* pNode = (SDataType*)pObj;
int32_t code = tjsonGetUTinyIntValue(pJson, jkDataTypeType, &pNode->type);
int32_t code = tjsonGetUSmallIntValue(pJson, jkDataTypeType, &pNode->type);
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetUTinyIntValue(pJson, jkDataTypePrecision, &pNode->precision);
}
......
......@@ -619,7 +619,7 @@ static int32_t dataTypeToMsg(const void* pObj, STlvEncoder* pEncoder) {
static int32_t msgToDataTypeInline(STlvDecoder* pDecoder, void* pObj) {
SDataType* pNode = (SDataType*)pObj;
int32_t code = tlvDecodeValueI8(pDecoder, &pNode->type);
int32_t code = tlvDecodeValueU16(pDecoder, &pNode->type);
if (TSDB_CODE_SUCCESS == code) {
code = tlvDecodeValueU8(pDecoder, &pNode->precision);
}
......@@ -641,7 +641,7 @@ static int32_t msgToDataType(STlvDecoder* pDecoder, void* pObj) {
tlvForEach(pDecoder, pTlv, code) {
switch (pTlv->type) {
case DATA_TYPE_CODE_TYPE:
code = tlvDecodeI8(pTlv, &pNode->type);
code = tlvDecodeU16(pTlv, &pNode->type);
break;
case DATA_TYPE_CODE_PRECISION:
code = tlvDecodeU8(pTlv, &pNode->precision);
......
......@@ -250,6 +250,13 @@ int32_t tjsonGetUIntValue(const SJson* pJson, const char* pName, uint32_t* pVal)
return code;
}
int32_t tjsonGetUSmallIntValue(const SJson* pJson, const char* pName, uint16_t* pVal) {
uint64_t val = 0;
int32_t code = tjsonGetUBigIntValue(pJson, pName, &val);
*pVal = val;
return code;
}
int32_t tjsonGetUTinyIntValue(const SJson* pJson, const char* pName, uint8_t* pVal) {
uint64_t val = 0;
int32_t code = tjsonGetUBigIntValue(pJson, pName, &val);
......@@ -375,4 +382,4 @@ bool tjsonValidateJson(const char* jIn) {
return true;
}
const char* tjsonGetError() { return cJSON_GetErrorPtr(); }
\ No newline at end of file
const char* tjsonGetError() { return cJSON_GetErrorPtr(); }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册