bChargeDeviceInserted = 0;
//low bat popup during charging device removing
if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) == 0) {
- if(bat_state < VCONFKEY_SYSMAN_BAT_NORMAL) {
+ if (bat_state < VCONFKEY_SYSMAN_BAT_NORMAL ||
+ bat_state == VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF) {
bundle *b = NULL;
b = bundle_create();
if(bat_state == VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF)
char *buf, *bufp;
int nargs = 0;
int escape = 0, squote = 0, dquote = 0;
- int bufsize = strlen(cmdline)+1;
+ int bufsize;
if (cmdline == NULL || cmdline[0] == '\0')
return -1;
-
+ bufsize = strlen(cmdline)+1;
bufp = buf = malloc(bufsize);
if (bufp == NULL || buf == NULL)
return -1;
}
chdir("/sys/block");
- while (dir = readdir(dp)) {
+ while ((dir = readdir(dp)) != NULL) {
memset(&stat, 0, sizeof(struct stat));
- lstat(dir->d_name, &stat);
+ if (lstat(dir->d_name, &stat) < 0)
+ continue;
if (S_ISDIR(stat.st_mode) || S_ISLNK(stat.st_mode)) {
if (strncmp(".", dir->d_name, 1) == 0
|| strncmp("..", dir->d_name, 2) == 0)
if (fd == -1) {
PRT_TRACE_ERR("%s open error: %s", buf,
strerror(errno));
- return -1;
+ continue;
}
r = read(fd, buf, 10);
if ((r >= 0) && (r < 10))
static void make_memps_log(char *file, pid_t pid, char *victim_name)
{
time_t now;
- struct tm *cur_tm;
+ struct tm cur_tm;
char params[4096];
char new_log[NAME_MAX];
static pid_t old_pid = 0;
old_pid = pid;
now = time(NULL);
- cur_tm = (struct tm *)malloc(sizeof(struct tm));
- if (cur_tm == NULL) {
- PRT_TRACE_ERR("Fail to memory allocation");
- return;
- }
- if (localtime_r(&now, cur_tm) == NULL) {
+ if (localtime_r(&now, &cur_tm) == NULL) {
PRT_TRACE_ERR("Fail to get localtime");
return;
}
PRT_TRACE("%s_%s_%d_%.4d%.2d%.2d_%.2d%.2d%.2d.log", file, victim_name,
- pid, (1900 + cur_tm->tm_year), 1 + cur_tm->tm_mon,
- cur_tm->tm_mday, cur_tm->tm_hour, cur_tm->tm_min,
- cur_tm->tm_sec);
+ pid, (1900 + cur_tm.tm_year), 1 + cur_tm.tm_mon,
+ cur_tm.tm_mday, cur_tm.tm_hour, cur_tm.tm_min,
+ cur_tm.tm_sec);
snprintf(new_log, sizeof(new_log),
"%s_%s_%d_%.4d%.2d%.2d_%.2d%.2d%.2d.log", file, victim_name,
- pid, (1900 + cur_tm->tm_year), 1 + cur_tm->tm_mon,
- cur_tm->tm_mday, cur_tm->tm_hour, cur_tm->tm_min,
- cur_tm->tm_sec);
+ pid, (1900 + cur_tm.tm_year), 1 + cur_tm.tm_mon,
+ cur_tm.tm_mday, cur_tm.tm_hour, cur_tm.tm_min,
+ cur_tm.tm_sec);
snprintf(params, sizeof(params), "-f %s", new_log);
ret = ss_launch_evenif_exist(MEMPS_EXEC_PATH, params);
fclose(fp);
}
}
- free(cur_tm);
}
static int lowmem_get_victim_pid()