提交 fc5e4563 编写于 作者: A Alex Duan

fix(shell): coverity scan problem fixed

上级 e13e611d
...@@ -325,30 +325,26 @@ void matchPrefixFromTree(STire* tire, char* prefix, SMatch* match) { ...@@ -325,30 +325,26 @@ void matchPrefixFromTree(STire* tire, char* prefix, SMatch* match) {
} }
SMatch* matchPrefix(STire* tire, char* prefix, SMatch* match) { SMatch* matchPrefix(STire* tire, char* prefix, SMatch* match) {
if(match == NULL) { SMatch* rMatch = match; // define return match
match = (SMatch* )tmalloc(sizeof(SMatch)); if (rMatch == NULL) {
memset(match, 0, sizeof(SMatch)); rMatch = (SMatch*)taosMemoryMalloc(sizeof(SMatch));
} memset(rMatch, 0, sizeof(SMatch));
}
switch (tire->type) {
case TIRE_TREE: switch (tire->type) {
matchPrefixFromTree(tire, prefix, match); case TIRE_TREE:
case TIRE_LIST: matchPrefixFromTree(tire, prefix, rMatch);
matchPrefixFromList(tire, prefix, match); break;
default: case TIRE_LIST:
break; matchPrefixFromList(tire, prefix, rMatch);
} break;
default:
// return if need break;
if (match->count == 0) { }
freeMatch(match);
match = NULL; return rMatch;
}
return match;
} }
// get all items from tires tree // get all items from tires tree
void enumFromList(STire* tire, SMatch* match) { void enumFromList(STire* tire, SMatch* match) {
StrName * item = tire->head; StrName * item = tire->head;
...@@ -395,8 +391,10 @@ SMatch* enumAll(STire* tire) { ...@@ -395,8 +391,10 @@ SMatch* enumAll(STire* tire) {
switch (tire->type) { switch (tire->type) {
case TIRE_TREE: case TIRE_TREE:
enumFromTree(tire, match); enumFromTree(tire, match);
break;
case TIRE_LIST: case TIRE_LIST:
enumFromList(tire, match); enumFromList(tire, match);
break;
default: default:
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册