deviced: Fix wrong type cast on 64bit build machine 34/32434/4
authorJiyoung Yun <jy910.yun@samsung.com>
Thu, 18 Dec 2014 07:21:41 +0000 (16:21 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Fri, 19 Dec 2014 04:30:52 +0000 (13:30 +0900)
Deviced sometimes pass int value to void * value.
It occurs warning on 64bit build machine
so I fixed wrong type cast from int to 64bit value.

Change-Id: If68a26d5911b803a0793488da64fd22fd1d92867
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
17 files changed:
src/battery/lowbat-handler.c
src/core/device-change-handler.c
src/core/device-notifier.c
src/core/main.c
src/display/auto-brightness.c
src/display/brightness.c
src/display/core.c
src/display/device-interface.c
src/display/key-filter.c
src/display/poll.c
src/display/setting.c
src/power/power-handler.c
src/power/power-handler.h
src/proc/proc-handler.c
src/storage/storage.c
src/telephony/telephony.c
src/time/time-handler.c

index 2b92275..48ae318 100644 (file)
@@ -565,7 +565,7 @@ static int booting_done(void *data)
 
        if (data == NULL)
                goto out;
-       done = (int)data;
+       done = *(int*)data;
        if (!done)
                goto out;
        _I("booting done");
index 21ed8ea..7cc32d8 100644 (file)
@@ -330,9 +330,13 @@ static void usb_chgdet_cb(void *data)
 
 static int display_changed(void *data)
 {
-       enum state_t state = (enum state_t)data;
+       enum state_t state;
        int ret, cradle = 0;
 
+       if (!data)
+               return 0;
+
+       state = *(int*)data;
        if (state != S_NORMAL)
                return 0;
 
@@ -524,14 +528,14 @@ static void hdmi_chgdet_cb(void *data)
        _I("jack - hdmi changed %d", val);
        vconf_set_int(VCONFKEY_SYSMAN_HDMI, val);
        hdmi_status = val;
-       device_notify(DEVICE_NOTIFIER_HDMI, (void *)val);
+       device_notify(DEVICE_NOTIFIER_HDMI, &val);
 
        if(val == 1) {
                pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0);
        } else {
                pm_unlock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, PM_SLEEP_MARGIN);
        }
-       hdmi_cec_execute((void *)val);
+       hdmi_cec_execute(&val);
 }
 
 static void hdcp_send_broadcast(int status)
@@ -719,7 +723,7 @@ static int booting_done(void *data)
 
        if (data == NULL)
                return done;
-       done = (int)data;
+       done = *(int*)data;
        if (done == 0)
                return done;
 
index 5e5aa83..c000f3a 100644 (file)
@@ -121,7 +121,7 @@ static int booting_done(void *data)
        if (data == NULL)
                goto out;
 
-       done = (int)data;
+       done = *(int*)data;
        if (late_init_timer == NULL)
                return done;
        late_init_stop();
@@ -138,7 +138,7 @@ static Eina_Bool late_init_timer_cb(void *data)
        if (done)
                return EINA_FALSE;
        _I("late booting done");
-       device_notify(DEVICE_NOTIFIER_BOOTING_DONE, (void *)TRUE);
+       device_notify(DEVICE_NOTIFIER_BOOTING_DONE, &done);
        return EINA_FALSE;
 }
 
index ab3e80c..d28aec7 100644 (file)
@@ -63,7 +63,7 @@ static int deviced_main(int argc, char **argv)
        ret = check_systemd_active();
        if (ret == TRUE) {
                _I("notify relaunch");
-               device_notify(DEVICE_NOTIFIER_BOOTING_DONE, (void *)TRUE);
+               device_notify(DEVICE_NOTIFIER_BOOTING_DONE, &ret);
        }
        signal(SIGTERM, sig_quit);
        signal(SIGUSR1, sig_usr1);
index d88e077..14052fb 100644 (file)
@@ -659,8 +659,12 @@ static int reset_autobrightness_min(char *name, enum watch_id id)
 
 static int lcd_changed_cb(void *data)
 {
-       int lcd_state = (int)data;
+       int lcd_state;
 
+       if (!data)
+               return 0;
+
+       lcd_state = *(int*)data;
        if (lcd_state == S_LCDOFF && alc_timeout_id > 0) {
                ecore_timer_del(alc_timeout_id);
                alc_timeout_id = NULL;
index 370de9a..5ebab8d 100644 (file)
@@ -175,8 +175,12 @@ int control_brightness_key(int action)
 
 static int lcd_changed_cb(void *data)
 {
-       int lcd_state = (int)data;
+       int lcd_state;
 
+       if (!data)
+               return 0;
+
+       lcd_state = *(int*)data;
        if (lcd_state == S_LCDOFF && popup_pid > 0) {
                if (popup_timer)
                        ecore_timer_del(popup_timer);
index 2f2df3a..2871878 100644 (file)
@@ -508,8 +508,13 @@ static Eina_Bool del_dim_cond(void *data)
 {
        PmLockNode *tmp = NULL;
        char pname[PATH_MAX];
-       pid_t pid = (pid_t)data;
+       pid_t pid;
+
+       if (!data)
+               return EINA_FALSE;
 
+       /* A passed data is a pid_t type data, not a 64bit data. */
+       pid = (pid_t)((intptr_t)data);
        _I("delete prohibit dim condition by timeout (%d)", pid);
 
        tmp = find_node(S_LCDDIM, pid);
@@ -527,8 +532,13 @@ static Eina_Bool del_off_cond(void *data)
 {
        PmLockNode *tmp = NULL;
        char pname[PATH_MAX];
-       pid_t pid = (pid_t)data;
+       pid_t pid;
+
+       if (!data)
+               return EINA_FALSE;
 
+       /* A passed data is a pid_t type data, not a 64bit data. */
+       pid = (pid_t)((intptr_t)data);
        _I("delete prohibit off condition by timeout (%d)", pid);
 
        tmp = find_node(S_LCDOFF, pid);
@@ -546,8 +556,13 @@ static Eina_Bool del_sleep_cond(void *data)
 {
        PmLockNode *tmp = NULL;
        char pname[PATH_MAX];
-       pid_t pid = (pid_t)data;
+       pid_t pid;
+
+       if (!data)
+               return EINA_FALSE;
 
+       /* A passed data is a pid_t type data, not a 64bit data. */
+       pid = (pid_t)((intptr_t)data);
        _I("delete prohibit sleep condition by timeout (%d)", pid);
 
        tmp = find_node(S_SLEEP, pid);
@@ -558,7 +573,7 @@ static Eina_Bool del_sleep_cond(void *data)
        if (!timeout_src_id)
                states[pm_cur_state].trans(EVENT_TIMEOUT);
 
-       set_process_active(EINA_FALSE, (pid_t)data);
+       set_process_active(EINA_FALSE, pid);
 
        return EINA_FALSE;
 }
@@ -880,15 +895,15 @@ static void set_standby_mode(pid_t pid, int enable)
 {
        Eina_List *l = NULL;
        Eina_List *l_next = NULL;
-       int *data = 0;
+       void *data;
 
        if (enable) {
                EINA_LIST_FOREACH(standby_mode_list, l, data)
-                       if (pid == (int) data) {
+                       if (pid == (pid_t)((intptr_t)data)) {
                                _E("%d already acquired standby mode", pid);
                                return;
                        }
-               EINA_LIST_APPEND(standby_mode_list, (void *)pid);
+               EINA_LIST_APPEND(standby_mode_list, (void *)((intptr_t)pid));
                _I("%d acquire standby mode", pid);
                if (standby_mode)
                        return;
@@ -901,7 +916,7 @@ static void set_standby_mode(pid_t pid, int enable)
                if (!standby_mode)
                        return;
                EINA_LIST_FOREACH_SAFE(standby_mode_list, l, l_next, data)
-                       if (pid == (int) data) {
+                       if (pid == (pid_t)((intptr_t)data)) {
                                standby_mode_list = eina_list_remove_list(
                                                    standby_mode_list, l);
                                _I("%d release standby mode", pid);
@@ -971,9 +986,14 @@ static int proc_condition(PMMsg *data)
 
        if (val & MASK_DIM) {
                if (data->timeout > 0) {
+                       /*
+                        * To pass a pid_t data through the timer infrastructure
+                        * without memory allocation, a pid_t data becomes typecast
+                        * to intptr_t and void *(64bit) type.
+                        */
                        cond_timeout_id =
                            ecore_timer_add(MSEC_TO_SEC(data->timeout),
-                                   (Ecore_Task_Cb)del_dim_cond, (void*)pid);
+                                   (Ecore_Task_Cb)del_dim_cond, (void*)((intptr_t)pid));
                }
                holdkey_block = GET_HOLDKEY_BLOCK_STATE(val);
                tmp = find_node(S_LCDDIM, pid);
@@ -997,9 +1017,14 @@ static int proc_condition(PMMsg *data)
        }
        if (val & MASK_OFF) {
                if (data->timeout > 0) {
+                       /*
+                        * To pass a pid_t data through the timer infrastructure
+                        * without memory allocation, a pid_t data becomes typecast
+                        * to intptr_t and void *(64bit) type.
+                        */
                        cond_timeout_id =
                            ecore_timer_add(MSEC_TO_SEC(data->timeout),
-                                   (Ecore_Task_Cb)del_off_cond, (void*)pid);
+                                   (Ecore_Task_Cb)del_off_cond, (void*)((intptr_t)pid));
                }
                holdkey_block = GET_HOLDKEY_BLOCK_STATE(val);
                tmp = find_node(S_LCDOFF, pid);
@@ -1031,9 +1056,14 @@ static int proc_condition(PMMsg *data)
                        proc_change_state(S_LCDOFF <<
                            (SHIFT_CHANGE_STATE + S_LCDOFF), getpid());
                if (data->timeout > 0) {
+                       /*
+                        * To pass a pid_t data through the timer infrastructure
+                        * without memory allocation, a pid_t data becomes typecast
+                        * to intptr_t and void *(64bit) type.
+                        */
                        cond_timeout_id =
                            ecore_timer_add(MSEC_TO_SEC(data->timeout),
-                                   (Ecore_Task_Cb)del_sleep_cond, (void*)pid);
+                                   (Ecore_Task_Cb)del_sleep_cond, (void*)((intptr_t)pid));
                }
                if (GET_STANDBY_MODE_STATE(val))
                        set_standby_mode(pid, true);
@@ -1312,7 +1342,7 @@ void print_info(int fd)
        char buf[255];
        int i = 1, ret;
        Eina_List *l = NULL;
-       int *data = 0;
+       void *data;
        char pname[PATH_MAX];
 
        if (fd < 0)
@@ -1363,7 +1393,7 @@ void print_info(int fd)
                write(fd, buf, strlen(buf));
 
                EINA_LIST_FOREACH(standby_mode_list, l, data) {
-                       get_pname((pid_t)data, pname);
+                       get_pname((pid_t)((intptr_t)data), pname);
                        snprintf(buf, sizeof(buf),
                            "  standby mode acquired by pid %d"
                            " - process %s\n", data, pname);
@@ -1628,7 +1658,7 @@ static int default_action(int timeout)
        if (pm_cur_state != pm_old_state && pm_cur_state != S_SLEEP) {
                if (power_ops.get_power_lock_support())
                        power_ops.power_lock();
-               device_notify(DEVICE_NOTIFIER_LCD, (void *)pm_cur_state);
+               device_notify(DEVICE_NOTIFIER_LCD, &pm_cur_state);
        }
 
        if (pm_old_state == S_NORMAL && pm_cur_state != S_NORMAL) {
@@ -2168,15 +2198,20 @@ int get_hdmi_state(void)
 
 static int hdmi_changed(void *data)
 {
-       hdmi_state = (int)data;
+       if (data)
+               hdmi_state = *(int*)data;
 
        return 0;
 }
 
 static int hall_ic_open(void *data)
 {
-       int open = (int)data;
+       int open;
+
+       if (!data)
+               return -EINVAL;
 
+       open = *(int*)data;
        update_pm_setting(SETTING_HALLIC_OPEN, open);
 
        if (display_info.update_auto_brightness)
@@ -2213,12 +2248,13 @@ static int booting_done(void *data)
 {
        static bool done = false;
 
-       if (done)
-               return 0;
-
-       _I("booting done, unlock LCD_OFF");
-       pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
-       done = true;
+       if (data != NULL) {
+               done = *(int*)data;
+               if (done)
+                       return 0;
+               _I("booting done, unlock LCD_OFF");
+               pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
+       }
 
        return 0;
 }
index f1c7f39..7c9575d 100644 (file)
@@ -200,7 +200,7 @@ static void *_system_suspend_cb(void *data)
        if (ret < 0)
                _E("Failed to system suspend! %d", ret);
 
-       return (void *)ret;
+       return NULL;
 }
 
 static int system_suspend(void)
index c59e5cd..ab3f48d 100644 (file)
@@ -781,8 +781,12 @@ static void hardkey_duration_cb(keynode_t *key, void *data)
 
 static int hardkey_lcd_changed_cb(void *data)
 {
-       int lcd_state = (int)data;
+       int lcd_state;
 
+       if (!data)
+               return 0;
+
+       lcd_state = *(int*)data;
        if (lcd_state == S_NORMAL
            && hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_ON) {
                turnon_hardkey_backlight();
index 8fba440..2ea191b 100644 (file)
@@ -77,11 +77,13 @@ static Eina_Bool pm_handler(void *data, Ecore_Fd_Handler *fd_handler)
 {
        char buf[1024];
        struct sockaddr_un clientaddr;
-
-       int fd = (int)data;
+       int fd;
        int ret;
        static const struct device_ops *display_device_ops = NULL;
 
+       if (!data)
+               return EINA_FALSE;
+
        FIND_DEVICE_INT(display_device_ops, "display");
 
        if (device_get_status(display_device_ops) != DEVICE_OPS_STATUS_START) {
@@ -93,6 +95,8 @@ static Eina_Bool pm_handler(void *data, Ecore_Fd_Handler *fd_handler)
                return EINA_FALSE;
        }
 
+       /* A passed data is a fd type data, not a 64bit data. */
+       fd = (int)((intptr_t)data);
        ret = read(fd, buf, sizeof(buf));
        CHECK_KEY_FILTER(ret, buf, fd);
        (*g_pm_callback) (INPUT_POLL_EVENT, NULL);
@@ -159,9 +163,14 @@ int init_pm_poll(int (*pm_callback) (int, PMMsg *))
                        goto out1;
                }
 
+               /*
+                * To pass a fd data through the fd hander infrastructure
+                * without memory allocation, a fd data becomes typecast
+                * to intptr_t and void *(64bit) type.
+                */
                fd_handler = ecore_main_fd_handler_add(fd,
                                    ECORE_FD_READ|ECORE_FD_ERROR,
-                                   pm_handler, (void *)fd, NULL, NULL);
+                                   pm_handler, (void *)((intptr_t)fd), NULL, NULL);
                if (fd_handler == NULL) {
                        _E("Failed ecore_main_handler_add() in init_pm_poll()");
                        goto out2;
@@ -264,9 +273,14 @@ int init_pm_poll_input(int (*pm_callback)(int , PMMsg * ), const char *path)
        }
        strncpy(dev_path, path, strlen(path) +1);
 
+       /*
+        * To pass a fd data through the fd hander infrastructure
+        * without memory allocation, a fd data becomes typecast
+        * to intptr_t and void *(64bit) type.
+        */
        fd_handler = ecore_main_fd_handler_add(fd,
                            ECORE_FD_READ|ECORE_FD_ERROR,
-                           pm_handler, (void *)fd, NULL, NULL);
+                           pm_handler, (void *)((intptr_t)fd), NULL, NULL);
        if (!fd_handler) {
                _E("Fail to ecore fd handler add! %s", path);
                close(fd);
index e0011f4..74b43a0 100644 (file)
@@ -200,19 +200,24 @@ int set_custom_lcdon_timeout(int timeout)
 static int setting_cb(keynode_t *key_nodes, void *data)
 {
        keynode_t *tmp = key_nodes;
+       int index;
 
-       if ((int)data > SETTING_END) {
+       if (!data)
+               return -EINVAL;
+
+       index = (int)((intptr_t)data);
+       if (index > SETTING_END) {
                _E("Unknown setting key: %s, idx=%d",
-                      vconf_keynode_get_name(tmp), (int)data);
+                      vconf_keynode_get_name(tmp), index);
                return -1;
        }
        if (update_pm_setting != NULL) {
-               switch((int)data) {
+               switch(index) {
                        case SETTING_ACCESSIBILITY_TTS:
-                               update_pm_setting((int)data, vconf_keynode_get_bool(tmp));
+                               update_pm_setting(index, vconf_keynode_get_bool(tmp));
                                break;
                        default:
-                               update_pm_setting((int)data, vconf_keynode_get_int(tmp));
+                               update_pm_setting(index, vconf_keynode_get_int(tmp));
                                break;
                }
        }
@@ -228,8 +233,13 @@ int init_setting(int (*func) (int key_idx, int val))
                update_pm_setting = func;
 
        for (i = SETTING_BEGIN; i < SETTING_GET_END; i++) {
+               /*
+                * To pass an index data through the vconf infratstructure
+                * without memory allocation, an index data becomes typecast
+                * to proper pointer size on each architecture.
+                */
                vconf_notify_key_changed(setting_keys[i], (void *)setting_cb,
-                                        (void *)i);
+                                        (void *)((intptr_t)i));
        }
 
        return 0;
index 231cca8..1d2afcc 100644 (file)
@@ -207,7 +207,7 @@ static int power_reboot(int type)
                ret = telephony_exit(POWER_REBOOT);
 
        if (ret < 0) {
-               restart_ap((void *)type);
+               restart_ap(type);
                return 0;
        }
        return ret;
@@ -273,7 +273,7 @@ static int booting_done(void *data)
        if (data == NULL)
                goto out;
 
-       done = (int)data;
+       done = *(int*)data;
        telephony_init();
 out:
        return done;
@@ -292,7 +292,7 @@ static void booting_done_edbus_signal_handler(void *data, DBusMessage *msg)
                return;
 
        _I("signal booting done");
-       device_notify(DEVICE_NOTIFIER_BOOTING_DONE, (void *)TRUE);
+       device_notify(DEVICE_NOTIFIER_BOOTING_DONE, &done);
 }
 
 static void poweroff_send_broadcast(int status)
@@ -353,14 +353,14 @@ static void poweroff_control_cb(keynode_t *in_key, void *data)
 
        switch (val) {
        case VCONFKEY_SYSMAN_POWER_OFF_DIRECT:
-               device_notify(DEVICE_NOTIFIER_POWEROFF, (void *)val);
+               device_notify(DEVICE_NOTIFIER_POWEROFF, &val);
                poweroff();
                break;
        case VCONFKEY_SYSMAN_POWER_OFF_POPUP:
                pwroff_popup();
                break;
        case VCONFKEY_SYSMAN_POWER_OFF_RESTART:
-               device_notify(DEVICE_NOTIFIER_POWEROFF, (void *)val);
+               device_notify(DEVICE_NOTIFIER_POWEROFF, &val);
                power_reboot(recovery);
                break;
        }
@@ -515,11 +515,11 @@ void powerdown_ap(void *data)
        reboot(RB_POWER_OFF);
 }
 
-void restart_ap(void *data)
+void restart_ap(int data)
 {
-       _I("Restart %d", (int)data);
+       _I("Restart %d", data);
        powerdown();
-       restart_by_mode((int)data);
+       restart_by_mode(data);
 }
 
 static const struct edbus_method edbus_methods[] = {
index e01c600..322c30b 100644 (file)
@@ -39,7 +39,7 @@
 #define SYSTEMD_STOP_POWER_RESTART_FOTA         7
 
 #ifndef SYSTEMD_SHUTDOWN
-void restart_ap(void *data);
+void restart_ap(int data);
 void powerdown_ap(void *data);
 #endif
 
index c226bfe..25bac1f 100644 (file)
@@ -729,7 +729,7 @@ static int proc_booting_done(void *data)
 
        if (data == NULL)
                goto out;
-       done = (int)data;
+       done = *(int*)data;
        if (vconf_notify_key_changed(VCONFKEY_PM_STATE, (void *)siop_mode_lcd, NULL) < 0)
                _E("Vconf notify key chaneged failed: KEY(%s)", VCONFKEY_PM_STATE);
        siop_mode_lcd(NULL, NULL);
index 60e4393..1394b67 100755 (executable)
@@ -366,7 +366,7 @@ static int booting_done(void *data)
        static int done = 0;
 
        if (data != NULL) {
-               done = (int)data;
+               done = *(int*)data;
                if (done)
                        _I("booting done");
                if (__memnoti_fd_init() == -1)
index 8841a31..4d75554 100644 (file)
@@ -57,7 +57,7 @@ static void telephony_powerdown_ap(TapiHandle *handle, const char *noti_id, void
 
 static void telephony_restart_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
 {
-       restart_ap((void *)reboot_opt);
+       restart_ap(reboot_opt);
 }
 
 static Eina_Bool telephony_restart_ap_by_force(void *data)
index db049d6..879c1a9 100644 (file)
@@ -332,9 +332,13 @@ static const struct edbus_method edbus_methods[] = {
 
 static int time_lcd_changed_cb(void *data)
 {
-       int lcd_state = (int)data;
+       int lcd_state;
        int tfd = -1;
 
+       if (!data)
+               return 0;
+
+       lcd_state = *(int*)data;
        if (lcd_state < S_LCDOFF)
                goto restart;