From f38cd651b87cba5f8a299f5f9ad8b6991da8e4f2 Mon Sep 17 00:00:00 2001 From: Taeyoung Kim Date: Mon, 28 Dec 2015 17:01:15 +0900 Subject: [PATCH] libdeviced: fix warnings occurred during compiling - type mismatches are fixed - unused functions and variables are removed - missed header files are added Change-Id: I6f91fc82e047e9dd9e19ad5ab4216f61b88bc705 Signed-off-by: Taeyoung Kim --- src/deviced/dd-storage.h | 2 +- src/libdeviced/control.c | 1 + src/libdeviced/dbus.c | 1 + src/libdeviced/deviced-conf.c | 2 +- src/libdeviced/deviced-noti.c | 39 +++++---------------------------------- src/libdeviced/haptic.c | 27 +++++++++++++-------------- src/libdeviced/storage.c | 16 +--------------- src/shared/dbus.h | 2 +- 8 files changed, 24 insertions(+), 66 deletions(-) diff --git a/src/deviced/dd-storage.h b/src/deviced/dd-storage.h index deb3cd8..9181e91 100644 --- a/src/deviced/dd-storage.h +++ b/src/deviced/dd-storage.h @@ -65,7 +65,7 @@ enum storage_path_type { * ... * @endcode */ -int storage_get_path(int type, unsigned char *path, int size); +int storage_get_path(int type, char *path, int size); /** * @} // end of CAPI_SYSTEM_DEVICED_STORAGE_MODULE diff --git a/src/libdeviced/control.c b/src/libdeviced/control.c index 3f53530..cc94947 100644 --- a/src/libdeviced/control.c +++ b/src/libdeviced/control.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "log.h" #include "dbus.h" diff --git a/src/libdeviced/dbus.c b/src/libdeviced/dbus.c index d62e8fc..7b6a6e7 100644 --- a/src/libdeviced/dbus.c +++ b/src/libdeviced/dbus.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "common.h" #include "log.h" diff --git a/src/libdeviced/deviced-conf.c b/src/libdeviced/deviced-conf.c index 0d3cb1c..f6e442f 100644 --- a/src/libdeviced/deviced-conf.c +++ b/src/libdeviced/deviced-conf.c @@ -18,6 +18,7 @@ #include +#include #include #include #include @@ -267,7 +268,6 @@ API int deviced_conf_is_vip(int pid) API int deviced_conf_set_permanent_bypid(int pid) { - int fd; if (already_permanent(pid)) goto MEMPOL_SET; diff --git a/src/libdeviced/deviced-noti.c b/src/libdeviced/deviced-noti.c index 0277f36..812f63c 100644 --- a/src/libdeviced/deviced-noti.c +++ b/src/libdeviced/deviced-noti.c @@ -78,8 +78,12 @@ static inline int send_str(int fd, char *str) len = strlen(str); if (len > SYSTEM_NOTI_MAXSTR) len = SYSTEM_NOTI_MAXSTR; - write(fd, &len, sizeof(int)); + ret = write(fd, &len, sizeof(int)); + if (ret < 0) + _E("Failed to write (%d)", errno); ret = write(fd, str, len); + if (ret < 0) + _E("Failed to write (%d)", errno); } return ret; } @@ -142,38 +146,6 @@ static int noti_send(struct sysnoti *msg) return result; } -static int dbus_flightmode_handler(char* type, char *buf) -{ - DBusError err; - DBusMessage *msg; - char *pa[3]; - int ret, val; - - pa[0] = type; - pa[1] = "1"; - pa[2] = buf; - - msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, - pa[0], "sis", pa); - if (!msg) - return -EBADMSG; - - dbus_error_init(&err); - - ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID); - if (!ret) { - _E("no message : [%s:%s]", err.name, err.message); - val = -EBADMSG; - } - - dbus_message_unref(msg); - dbus_error_free(&err); - - _D("%s-%s : %d", DEVICED_INTERFACE_POWER, pa[0], val); - return val; -} - API int deviced_call_predef_action(const char *type, int num, ...) { struct sysnoti *msg; @@ -371,7 +343,6 @@ static DBusMessage *alarm_set_time_sync_with_reply(time_t timet) DBusMessageIter iter; DBusMessage *reply; DBusError err; - int r; conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); if (!conn) { diff --git a/src/libdeviced/haptic.c b/src/libdeviced/haptic.c index 255ae9d..40f090b 100644 --- a/src/libdeviced/haptic.c +++ b/src/libdeviced/haptic.c @@ -220,7 +220,7 @@ API int haptic_close(haptic_device_h device_handle) int ret; /* check if handle is valid */ - if (device_handle == NULL) { + if (!device_handle) { _E("Invalid parameter : device_handle"); return HAPTIC_ERROR_INVALID_PARAMETER; } @@ -261,7 +261,7 @@ API int haptic_vibrate_monotone_with_detail(haptic_device_h device_handle, int ret; /* check if handle is valid */ - if (device_handle == NULL) { + if (!device_handle) { _E("Invalid parameter : device_handle"); return HAPTIC_ERROR_INVALID_PARAMETER; } @@ -310,7 +310,7 @@ API int haptic_vibrate_monotone_with_detail(haptic_device_h device_handle, API int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path, haptic_effect_h *effect_handle) { - char *vibe_buffer; + unsigned char *vibe_buffer; int size, ret; vibe_buffer = convert_file_to_buffer(file_path, &size); @@ -320,7 +320,7 @@ API int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path } ret = haptic_vibrate_buffers_with_detail(device_handle, - vibe_buffer, + (const unsigned char *)vibe_buffer, size, HAPTIC_ITERATION_ONCE, HAPTIC_FEEDBACK_AUTO, @@ -337,7 +337,7 @@ API int haptic_vibrate_file_with_detail(haptic_device_h device_handle, haptic_priority_e priority, haptic_effect_h *effect_handle) { - char *vibe_buffer; + unsigned char *vibe_buffer; int size, ret; vibe_buffer = convert_file_to_buffer(file_path, &size); @@ -347,7 +347,7 @@ API int haptic_vibrate_file_with_detail(haptic_device_h device_handle, } ret = haptic_vibrate_buffers_with_detail(device_handle, - vibe_buffer, + (const unsigned char *)vibe_buffer, size, iteration, feedback, @@ -415,7 +415,7 @@ API int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle, int ret; /* check if handle is valid */ - if (device_handle == NULL) { + if (!device_handle) { _E("Invalid parameter : device_handle"); return HAPTIC_ERROR_INVALID_PARAMETER; } @@ -482,7 +482,7 @@ API int haptic_stop_all_effects(haptic_device_h device_handle) int ret; /* check if handle is valid */ - if (device_handle == NULL) { + if (!device_handle) { _E("Invalid parameter : device_handle"); return HAPTIC_ERROR_INVALID_PARAMETER; } @@ -507,7 +507,7 @@ API int haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h e int ret; /* check if handle is valid */ - if (device_handle == NULL) { + if (!device_handle) { _E("Invalid parameter : device_handle"); return HAPTIC_ERROR_INVALID_PARAMETER; } @@ -624,7 +624,7 @@ API int haptic_save_effect(const unsigned char *vibe_buffer, const char *file_path) { struct stat buf; - int size, ret; + int ret; /* check if passed arguments are valid */ if (vibe_buffer == NULL) { @@ -660,7 +660,7 @@ API int haptic_save_effect(const unsigned char *vibe_buffer, API int haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *file_duration) { - char *vibe_buffer; + unsigned char *vibe_buffer; int size, ret; vibe_buffer = convert_file_to_buffer(file_path, &size); @@ -670,7 +670,7 @@ API int haptic_get_file_duration(haptic_device_h device_handle, const char *file } ret = haptic_get_buffers_duration(device_handle, - vibe_buffer, + (const unsigned char *)vibe_buffer, size, file_duration); free(vibe_buffer); @@ -693,7 +693,7 @@ API int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigne int ret; /* check if handle is valid */ - if (device_handle == NULL) { + if (!device_handle) { _E("Invalid parameter : device_handle"); return HAPTIC_ERROR_INVALID_PARAMETER; } @@ -729,7 +729,6 @@ API int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigne API int haptic_save_led(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path) { struct stat buf; - char str_bufsize[32]; char *arr[3]; struct dbus_byte bytes; int ret; diff --git a/src/libdeviced/storage.c b/src/libdeviced/storage.c index aaf5eb0..3f0151b 100644 --- a/src/libdeviced/storage.c +++ b/src/libdeviced/storage.c @@ -33,23 +33,9 @@ #define EXT_PARENT_PATH "/opt/storage" #define EXT_OPTION1_PATH "/mnt/mmc" -static bool check_ext_mount(void) -{ - struct stat parent, ext; - - if (stat(EXT_PATH, &ext) != 0 || stat(EXT_PARENT_PATH, &parent) != 0) - return false; - - if (ext.st_dev == parent.st_dev) - return false; - - return true; -} - -API int storage_get_path(int type, unsigned char *path, int size) +API int storage_get_path(int type, char *path, int size) { char *ext_path = EXT_PATH; - int option; if (type < 0 || type > STORAGE_MAX || !path) return -EINVAL; diff --git a/src/shared/dbus.h b/src/shared/dbus.h index f79315c..4762b23 100644 --- a/src/shared/dbus.h +++ b/src/shared/dbus.h @@ -218,7 +218,7 @@ #define CRASHD_INTERFACE_CRASH CRASHD_INTERFACE_NAME".Crash" struct dbus_byte { - const char *data; + const unsigned char *data; int size; }; -- 2.7.4