Hotfix/sangshuduo/td 3197 taosdemo coverity scan for master (#7510)

* [TD-3197]<fix>: taosdemo and taosdump coverity scan issues.

* exit if read sample file failed.

* fix converity scan issue.

* fix coverity scan issue.

* fix coverity scan memory leak.

* fix resource leak reported by coverity scan.

* fix taosdemo coverity scan issue.

* fix tcsetattr and getchar return value determination bug.

Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
Shuduo Sang 2021-08-22 21:49:47 +08:00 committed by GitHub
parent ffcb8f6a4a
commit 9aa505f7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -177,7 +177,9 @@ static void parse_args(
fprintf(stderr, "password reading error\n");
}
taosSetConsoleEcho(true);
getchar();
if (EOF == getchar()) {
fprintf(stderr, "getchar() return EOF\n");
}
} else {
tstrncpy(g_password, (char *)(argv[i] + 2), SHELL_MAX_PASSWORD_LEN);
strcpy(argv[i], "-p");

View File

@ -63,12 +63,12 @@ int taosSetConsoleEcho(bool on)
}
if (on)
term.c_lflag|=ECHOFLAGS;
term.c_lflag |= ECHOFLAGS;
else
term.c_lflag &=~ECHOFLAGS;
term.c_lflag &= ~ECHOFLAGS;
err = tcsetattr(STDIN_FILENO,TCSAFLUSH,&term);
if (err == -1 && err == EINTR) {
err = tcsetattr(STDIN_FILENO, TCSAFLUSH, &term);
if (err == -1 || err == EINTR) {
perror("Cannot set the attribution of the terminal");
return -1;
}