Skip to content

Commit

Permalink
Fix static scan issues
Browse files Browse the repository at this point in the history
Tracked-On: OAM-110031
Signed-off-by: Zheng, XianjunX <[email protected]>
  • Loading branch information
xianju6x committed Mar 21, 2024
1 parent 43aaf13 commit 702833e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
10 changes: 7 additions & 3 deletions crashlog/crashutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ unsigned long long get_uptime(int refresh, int *error)
// Find system last kmsg from dropbox
static int find_system_last_kmsg(char source[], int source_length) {
struct dirent *entry;
DIR *dir = opendir(DROPBOX_DIR);
int file_exist = 0;

if (source == NULL) {
LOGE("source is NULL.\n");
return file_exist;
}
DIR *dir = opendir(DROPBOX_DIR);
if (dir == NULL) {
LOGE("No such directory: %s\n",DROPBOX_DIR);
return file_exist;
Expand Down Expand Up @@ -808,13 +808,17 @@ int process_info_and_error(char *filename, char *name) {
snprintf(path, sizeof(path),"%s/%s", filename,tmp_data_name);
snprintf(destion,sizeof(destion),"%s/%s", dir, tmp_data_name);
do_copy_tail(path, destion, 0);
remove(path);
if (remove(path) == -1) {
LOGE("Failed to remove path %s\n", path);
}
}
/*copy trigger file*/
snprintf(path, sizeof(path),"%s/%s", filename,name);
snprintf(destion,sizeof(destion),"%s/%s", dir,name);
do_copy_tail(path, destion, 0);
remove(path);
if (remove(path) == -1) {
LOGE("Failed to remove path %s\n", path);
}
/*create type */
snprintf(tmp,sizeof(tmp),"%s",name);
/*Set to upper case*/
Expand Down
7 changes: 4 additions & 3 deletions crashlog/fsutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ static inline int dir_exists(const char *dirpath) {
DIR * dir;

dir = opendir(dirpath);
if (dir != NULL)
if (dir != NULL) {
closedir(dirpath);
return 1;
else
return 0;
}
return 0;
}

static inline int get_file_size(char *filename) {
Expand Down
5 changes: 4 additions & 1 deletion crashlog/inotify_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,10 @@ int receive_inotify_events(int inotify_fd) {
entry = &wd_array[idx];
}
if ( entry && entry->eventpath ) {
mkdir(entry->eventpath, 0777); /* TO DO : restoring previous rights/owner/group ?*/
if ( mkdir(entry->eventpath, 0777) == -1 ) { /* TO DO : restoring previous rights/owner/group ?*/
LOGE("Can't mkdir %s.\n", entry->eventpath);
return -1;
}
inotify_rm_watch(inotify_fd, event->wd);
wd = inotify_add_watch(inotify_fd, entry->eventpath, entry->eventmask);
if ( wd < 0 ) {
Expand Down
8 changes: 6 additions & 2 deletions crashlog/trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,17 @@ int process_stat_event(struct watch_entry *entry, struct inotify_event *event) {
snprintf(path, sizeof(path), "%s/%s", entry->eventpath, tmp_data_name);
snprintf(destination, sizeof(destination), "%s/%s", dir, tmp_data_name);
do_copy(path, destination, MAXFILESIZE);
remove(path);
if (remove(path) == -1) {
LOGE("Failed to remove path %s\n", path);
}
}
/*copy trigger file*/
snprintf(path, sizeof(path),"%s/%s",entry->eventpath,event->name);
snprintf(destination,sizeof(destination),"%s/%s", dir, event->name);
do_copy(path, destination, MAXFILESIZE);
remove(path);
if (remove(path) == -1) {
LOGE("Failed to remove path %s\n", path);
}
/*create type */
snprintf(tmp,sizeof(tmp),"%s",event->name);
p = strstr(tmp,"_trigger");
Expand Down
4 changes: 3 additions & 1 deletion crashlog/usercrash.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ static int priv_process_usercrash_event(struct watch_entry *entry, struct inotif
do_log_copy(eventname, dir, get_current_time_short(1), APLOG_TYPE);
break;
case HPROF_TYPE:
remove(path);
if (remove(path) == -1) {
LOGE("Failed to remove path %s\n", path);
}
break;
default:
LOGE("%s: Unexpected type of event(%d)\n", __FUNCTION__, entry->eventtype);
Expand Down

0 comments on commit 702833e

Please sign in to comment.