提交 cf014abd 编写于 作者: F fang

solve some static check questions for shell/src/

上级 84d955e7
...@@ -780,6 +780,7 @@ void source_file(TAOS *con, char *fptr) { ...@@ -780,6 +780,7 @@ void source_file(TAOS *con, char *fptr) {
if (wordexp(fptr, &full_path, 0) != 0) { if (wordexp(fptr, &full_path, 0) != 0) {
fprintf(stderr, "ERROR: illegal file name\n"); fprintf(stderr, "ERROR: illegal file name\n");
free(cmd);
return; return;
} }
...@@ -788,6 +789,7 @@ void source_file(TAOS *con, char *fptr) { ...@@ -788,6 +789,7 @@ void source_file(TAOS *con, char *fptr) {
if (access(fname, R_OK) == -1) { if (access(fname, R_OK) == -1) {
fprintf(stderr, "ERROR: file %s is not readable\n", fptr); fprintf(stderr, "ERROR: file %s is not readable\n", fptr);
wordfree(&full_path); wordfree(&full_path);
free(cmd);
return; return;
} }
...@@ -795,6 +797,7 @@ void source_file(TAOS *con, char *fptr) { ...@@ -795,6 +797,7 @@ void source_file(TAOS *con, char *fptr) {
if (f == NULL) { if (f == NULL) {
fprintf(stderr, "ERROR: failed to open file %s\n", fname); fprintf(stderr, "ERROR: failed to open file %s\n", fname);
wordfree(&full_path); wordfree(&full_path);
free(cmd);
return; return;
} }
......
...@@ -277,7 +277,10 @@ void *shellLoopQuery(void *arg) { ...@@ -277,7 +277,10 @@ void *shellLoopQuery(void *arg) {
pthread_cleanup_push(cleanup_handler, NULL); pthread_cleanup_push(cleanup_handler, NULL);
char *command = malloc(MAX_COMMAND_SIZE); char *command = malloc(MAX_COMMAND_SIZE);
if (command == NULL){
tscError("failed to malloc command");
return NULL;
}
while (1) { while (1) {
// Read command from shell. // Read command from shell.
...@@ -286,10 +289,8 @@ void *shellLoopQuery(void *arg) { ...@@ -286,10 +289,8 @@ void *shellLoopQuery(void *arg) {
shellReadCommand(con, command); shellReadCommand(con, command);
reset_terminal_mode(); reset_terminal_mode();
if (command != NULL) { // Run the command
// Run the command shellRunCommand(con, command);
shellRunCommand(con, command);
}
} }
pthread_cleanup_pop(1); pthread_cleanup_pop(1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册