From e0491c091113033fdf2d8422608fbb0360d49eb5 Mon Sep 17 00:00:00 2001 From: Jinjin Shi Date: Wed, 9 Jan 2013 09:48:25 +0800 Subject: [PATCH] [UI]Remove prevent --- .../src/lockscreen-options-main.c | 4 +-- src/lock-daemon.c | 31 +++++++++++++------ src/pkg_event.c | 5 +++ src/starter.c | 1 + src/xmonitor.c | 6 +++- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/lock-setting/lockscreen-options/src/lockscreen-options-main.c b/lock-setting/lockscreen-options/src/lockscreen-options-main.c index 10e68a2..6a546f9 100755 --- a/lock-setting/lockscreen-options/src/lockscreen-options-main.c +++ b/lock-setting/lockscreen-options/src/lockscreen-options-main.c @@ -293,7 +293,7 @@ void lockscreen_options_main_create_view(lockscreen_options_ug_data * ug_data) if (lockscreen_options_menu_item[i].glStyle == ENUM_LOCKSCREEN_GENLIST_STYLE_1TEXT1ICON) { itc = &(itc_menu_1text1icon); - item = elm_genlist_item_append(genlist, + elm_genlist_item_append(genlist, itc, & (lockscreen_options_menu_item @@ -304,7 +304,7 @@ void lockscreen_options_main_create_view(lockscreen_options_ug_data * ug_data) } else if(lockscreen_options_menu_item[i].glStyle == ENUM_LOCKSCREEN_GENLIST_STYLE_2TEXT1ICON) { itc = &(itc_menu_2text1icon); - item = elm_genlist_item_append(genlist, + elm_genlist_item_append(genlist, itc, & (lockscreen_options_menu_item diff --git a/src/lock-daemon.c b/src/lock-daemon.c index d63fbd2..a577f01 100755 --- a/src/lock-daemon.c +++ b/src/lock-daemon.c @@ -290,13 +290,21 @@ static void lockd_unlock_lockscreen(struct lockd_data *lockd) inline static void lockd_set_sock_option(int fd, int cli) { int size; + int ret; struct timeval tv = { 1, 200 * 1000 }; size = PHLOCK_SOCK_MAXBUFF; - setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)); - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); - if (cli) - setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)); + if(ret != 0) + return; + ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); + if(ret != 0) + return; + if (cli) { + ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + if(ret != 0) + return; + } } static int lockd_create_sock(void) @@ -329,11 +337,13 @@ static int lockd_create_sock(void) if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { LOCKD_DBG("bind error"); + close(fd); return -1; } if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) { LOCKD_DBG("failed to change the socket permission"); + close(fd); return -1; } @@ -341,6 +351,7 @@ static int lockd_create_sock(void) if (listen(fd, 10) == -1) { LOCKD_DBG("listen error"); + close(fd); return -1; } @@ -460,12 +471,7 @@ static int lockd_sock_handler(void *data) lockd_set_sock_option(clifd, 1); len = recv(clifd, cmd, PHLOCK_SOCK_MAXBUFF, 0); - - if (cmd == NULL) { - LOCKD_DBG("recv error, cmd is NULL"); - close(clifd); - return -1; - } + cmd[PHLOCK_SOCK_MAXBUFF - 1] = '\0'; if (len != strlen(cmd)) { LOCKD_DBG("recv error %d %d", len, strlen(cmd)); @@ -504,6 +510,11 @@ static int lockd_sock_handler(void *data) } } + if(cmdline != NULL) { + free(cmdline); + cmdline = NULL; + } + close(clifd); return 0; } diff --git a/src/pkg_event.c b/src/pkg_event.c index 367e62f..fffb197 100755 --- a/src/pkg_event.c +++ b/src/pkg_event.c @@ -64,6 +64,10 @@ directory_notify(void* data, Ecore_Fd_Handler* fd_handler) fd = ecore_main_fd_handler_fd_get(fd_handler); _D("There are some modification, ifd [%d]", fd); + if(fd < 0) { + _E("Failed to get fd"); + return ECORE_CALLBACK_CANCEL; + } if (ioctl(fd, FIONREAD, &read_size) < 0) { _E("Failed to get q size"); @@ -86,6 +90,7 @@ directory_notify(void* data, Ecore_Fd_Handler* fd_handler) free(buf); return ECORE_CALLBACK_CANCEL; } + buf[read_size - 1] = '\0'; while (i < len) { struct inotify_event* event = (struct inotify_event*) &buf[i]; diff --git a/src/starter.c b/src/starter.c index ac7360b..d88a714 100755 --- a/src/starter.c +++ b/src/starter.c @@ -221,6 +221,7 @@ int main(int argc, char *argv[]) int heyfd = heynoti_init(); if (heyfd < 0) { _ERR("Failed to heynoti_init[%d]", heyfd); + return -1; } int ret = heynoti_subscribe(heyfd, "power_off_start", _heynoti_event_power_off, NULL); diff --git a/src/xmonitor.c b/src/xmonitor.c index 92d2a07..e5c441b 100755 --- a/src/xmonitor.c +++ b/src/xmonitor.c @@ -59,12 +59,16 @@ static inline int _get_pid(Ecore_X_Window win) { int pid; Ecore_X_Atom atom; - unsigned char *in_pid; + unsigned char *in_pid = NULL; int num; atom = ecore_x_atom_get("X_CLIENT_PID"); if (ecore_x_window_prop_property_get(win, atom, ECORE_X_ATOM_CARDINAL, sizeof(int), &in_pid, &num) == EINA_FALSE) { + if(in_pid != NULL) { + free(in_pid); + in_pid = NULL; + } if (ecore_x_netwm_pid_get(win, &pid) == EINA_FALSE) { _E("Failed to get PID from a window 0x%X", win); return -EINVAL; -- 2.34.1