solve some static check questions for shell/src/
This commit is contained in:
parent
84d955e738
commit
cf014abd96
|
@ -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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue