From: Youngjae Shin Date: Mon, 25 Sep 2017 10:40:38 +0000 (+0900) Subject: fix build warning and invalid coding rule X-Git-Tag: submit/tizen/20171013.001308^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c858c87affdde8f4ec87fb41bfe450855e89b5c;p=platform%2Fcore%2Fconnectivity%2Fdata-router.git fix build warning and invalid coding rule Change-Id: I3f00cfc5db6ae1b9084aaec38ff35ae3d95c2432 Signed-off-by: Youngjae Shin --- diff --git a/include/dr-ipc.h b/include/dr-ipc.h index 7708ff7..a5d9842 100644 --- a/include/dr-ipc.h +++ b/include/dr-ipc.h @@ -23,7 +23,7 @@ #ifndef _DR_IPC_H -#define _DR_IPC_H +#define _DR_IPC_H #include diff --git a/include/dr-main.h b/include/dr-main.h index 37399c9..3612717 100644 --- a/include/dr-main.h +++ b/include/dr-main.h @@ -42,10 +42,10 @@ -/** - * @def USB_BUFFER_SIZE - * Defines the maximum buffer size for the USB - */ +/** + * @def USB_BUFFER_SIZE + * Defines the maximum buffer size for the USB + */ #define USB_BUFFER_SIZE 1500 #define ERRMSG_SIZE 100 diff --git a/include/dr-parser.h b/include/dr-parser.h index d6a609e..ed58857 100644 --- a/include/dr-parser.h +++ b/include/dr-parser.h @@ -38,4 +38,4 @@ enum { int _get_at_cmd_type(char *buf); -#endif +#endif //_DR_PARSER_H_ diff --git a/include/dr-usb.h b/include/dr-usb.h index d088e0e..84e5416 100644 --- a/include/dr-usb.h +++ b/include/dr-usb.h @@ -23,7 +23,7 @@ #ifndef _DR_USB_H -#define _DR_USB_H +#define _DR_USB_H /* @@ -44,38 +44,38 @@ enum { /** @internal - * This function initialises the USB interface - * - * @return This function returns 0 if the USB has been initialised successfully or it returns -1 on failure - * - */ + * This function initialises the USB interface + * + * @return This function returns 0 if the USB has been initialised successfully or it returns -1 on failure + * + */ int _init_usb(void); /** @internal - * This function deinitialises the USB interface - */ + * This function deinitialises the USB interface + */ void _deinit_usb(void); /** @internal - * This function is used to write data to the USB interface - * - * @param [in] buf data to be written to USB - * @param [in] buf_len no of bytes of data to be written to USB - * @return This function returns the no of bytes written to the USB. - */ + * This function is used to write data to the USB interface + * + * @param [in] buf data to be written to USB + * @param [in] buf_len no of bytes of data to be written to USB + * @return This function returns the no of bytes written to the USB. + */ int _write_to_usb(char *buf, int buf_len); /** @internal - * This function is used to send modem line state to Host PC - * - * @param [in] ctrl status of control lines - * @return This function returns zero if successful else returns -EIO - * - */ + * This function is used to send modem line state to Host PC + * + * @param [in] ctrl status of control lines + * @return This function returns zero if successful else returns -EIO + * + */ int _send_usb_line_state(int ctrl); diff --git a/include/dr-util.h b/include/dr-util.h index 69b1eb5..069ad3d 100644 --- a/include/dr-util.h +++ b/include/dr-util.h @@ -29,4 +29,4 @@ int _system_cmd(const char *command); int _system_cmd_ext(const char *cmd, char *const arg_list[]); -#endif +#endif //_DR_UTIL_H_ diff --git a/src/dr-ipc.c b/src/dr-ipc.c index 99b5b33..13e66a5 100644 --- a/src/dr-ipc.c +++ b/src/dr-ipc.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -50,7 +49,7 @@ DBusConnection *dbus_connection = NULL; typedef enum { SERIAL_SESSION_DISCONNECTED, SERIAL_SESSION_CONNECTED -}dr_session_state_t; +} dr_session_state_t; typedef struct { int server_socket; @@ -59,13 +58,13 @@ typedef struct { int g_watch_id_client; GIOChannel *g_io; unsigned char state; -}dr_socket_info_t; +} dr_socket_info_t; dr_socket_info_t serial_session = {0, }; static DBusHandlerResult __dbus_event_filter(DBusConnection *sys_conn, - DBusMessage *msg, void *data) + DBusMessage *msg, void *data) { const char *path = dbus_message_get_path(msg); @@ -76,11 +75,11 @@ static DBusHandlerResult __dbus_event_filter(DBusConnection *sys_conn, return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (dbus_message_is_signal(msg, NETWORK_SERIAL_INTERFACE, - "ready_for_serial")) { + "ready_for_serial")) { char *res = NULL; dbus_message_get_args(msg, NULL, - DBUS_TYPE_STRING, &res, - DBUS_TYPE_INVALID); + DBUS_TYPE_STRING, &res, + DBUS_TYPE_INVALID); if (g_strcmp0(res, "OK") == 0) _send_serial_status_signal(SERIAL_OPENED); @@ -99,7 +98,7 @@ gboolean _init_dbus_signal(void) DBusError dbus_error; conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err); - if(!conn) { + if (!conn) { ERR(" DBUS get failed\n"); g_error_free(err); return FALSE; @@ -110,8 +109,8 @@ gboolean _init_dbus_signal(void) dbus_error_init(&dbus_error); dbus_connection_add_filter(dbus_connection, __dbus_event_filter, NULL, NULL); dbus_bus_add_match(dbus_connection, - "type=signal,interface=" NETWORK_SERIAL_INTERFACE - ",member=ready_for_serial", &dbus_error); + "type=signal,interface=" NETWORK_SERIAL_INTERFACE + ",member=ready_for_serial", &dbus_error); if (dbus_error_is_set(&dbus_error)) { ERR("Fail to add dbus filter signal\n"); dbus_error_free(&dbus_error); @@ -124,24 +123,24 @@ gboolean _init_dbus_signal(void) void _send_serial_status_signal(int event) { DBusMessage *msg = NULL; - if(dbus_connection == NULL) return; + if (dbus_connection == NULL) return; msg = dbus_message_new_signal("/DataRouter", - "User.Data.Router.Introspectable", - "serial_status"); + "User.Data.Router.Introspectable", + "serial_status"); if (!msg) { ERR("Unable to allocate D-Bus signal\n"); return; } if (!dbus_message_append_args(msg, - DBUS_TYPE_INT32, &event, - DBUS_TYPE_INVALID)) { + DBUS_TYPE_INT32, &event, + DBUS_TYPE_INVALID)) { ERR("Event sending failed\n"); dbus_message_unref(msg); return; } - DBG("Send dbus signal : %s\n", event ? "SERIAL_OPENED":"SERIAL_CLOSED"); + DBG("Send dbus signal : %s\n", event ? "SERIAL_OPENED" : "SERIAL_CLOSED"); dbus_connection_send(dbus_connection, msg, NULL); dbus_message_unref(msg); return; @@ -172,9 +171,9 @@ static void __close_client_socket() int ret; DBG("Closing socket\n"); ret = close(serial_session.client_socket); - if (ret == -1) { + if (ret == -1) perror("close error: "); - } + serial_session.state = SERIAL_SESSION_DISCONNECTED; return; } @@ -211,17 +210,17 @@ static gboolean __g_io_accept_handler(GIOChannel *chan, GIOCondition cond, gpoin socklen_t addrlen; addrlen = sizeof(client_addr); - if ( cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR) ) { + if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { DBG("GIOCondition %d \n", cond); - if(serial_session.server_socket >= 0) { + if (serial_session.server_socket >= 0) { close(serial_session.server_socket); serial_session.server_socket = 0; } return FALSE; } - if(serial_session.state == SERIAL_SESSION_CONNECTED) { + if (serial_session.state == SERIAL_SESSION_CONNECTED) { DBG("Connection already exists.....\n"); return FALSE; } @@ -235,10 +234,10 @@ static gboolean __g_io_accept_handler(GIOChannel *chan, GIOCondition cond, gpoin io = g_io_channel_unix_new(clientfd); g_io_channel_set_close_on_unref(io, TRUE); serial_session.g_watch_id_client = g_io_add_watch(io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, - __g_io_server_handler, NULL); + __g_io_server_handler, NULL); g_io_channel_unref(io); - serial_session.client_socket= clientfd; + serial_session.client_socket = clientfd; serial_session.state = SERIAL_SESSION_CONNECTED; } else { ERR("Accept failed\n"); @@ -287,8 +286,8 @@ static void __create_serial_server() serial_session.g_io = g_io_channel_unix_new(server_socket); g_io_channel_set_close_on_unref(serial_session.g_io, TRUE); serial_session.g_watch_id_server = g_io_add_watch(serial_session.g_io, - G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, - __g_io_accept_handler, NULL); + G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, + __g_io_accept_handler, NULL); g_io_channel_unref(serial_session.g_io); return; @@ -309,7 +308,7 @@ gboolean _deinit_serial_server(void) gboolean _is_exist_serial_session(void) { - return (serial_session.state == SERIAL_SESSION_CONNECTED) ? TRUE: FALSE; + return (serial_session.state == SERIAL_SESSION_CONNECTED) ? TRUE : FALSE; } gboolean _wait_serial_session(void) diff --git a/src/dr-main.c b/src/dr-main.c index d425fe0..6c6951b 100755 --- a/src/dr-main.c +++ b/src/dr-main.c @@ -66,9 +66,8 @@ gboolean _init_dr(void) /**************** USB ******************/ if (_get_usb_state(&usb_state) != -1) { - if (usb_state != VCONFKEY_SYSMAN_USB_DISCONNECTED ) { + if (usb_state != VCONFKEY_SYSMAN_USB_DISCONNECTED) _init_usb(); - } } DBG("-\n"); @@ -95,7 +94,7 @@ int main(int argc, char *argv[]) { DBG("+\n"); -#if !GLIB_CHECK_VERSION (2, 35, 0) +#if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif _init_dbus_signal(); diff --git a/src/dr-noti-handler.c b/src/dr-noti-handler.c index 0c8ce84..a99e05d 100755 --- a/src/dr-noti-handler.c +++ b/src/dr-noti-handler.c @@ -38,7 +38,7 @@ volatile gboolean dsr_status = FALSE; static gboolean acm_enabled(int mode) { - switch(mode) { + switch (mode) { case SET_USB_DEFAULT: case SET_USB_SDB: case SET_USB_SDB_DIAG: @@ -111,26 +111,25 @@ gboolean _register_vconf_notification(void) { int ret; - ret = - vconf_notify_key_changed(VCONFKEY_SYSMAN_USB_STATUS, (vconf_callback_fn) __usb_status_noti_handler, NULL); - if (ret < 0) { + ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_USB_STATUS, + (vconf_callback_fn)__usb_status_noti_handler, NULL); + if (ret < 0) ERR("Error !!! VCONFKEY reg noti : %s\n", VCONFKEY_SYSMAN_USB_STATUS); - } - ret = - vconf_notify_key_changed(VCONFKEY_USB_CUR_MODE, - (vconf_callback_fn) __usb_mode_noti_handler, NULL); - if (ret < 0) { + ret = vconf_notify_key_changed(VCONFKEY_USB_CUR_MODE, + (vconf_callback_fn) __usb_mode_noti_handler, NULL); + if (ret < 0) ERR("Error !!! VCONFKEY reg noti : %s\n", VCONFKEY_USB_CUR_MODE); - } return TRUE; } void _unregister_vconf_notification(void) { - vconf_ignore_key_changed(VCONFKEY_SYSMAN_USB_STATUS, (vconf_callback_fn) __usb_status_noti_handler); - vconf_ignore_key_changed(VCONFKEY_USB_CUR_MODE, (vconf_callback_fn) __usb_mode_noti_handler); + vconf_ignore_key_changed(VCONFKEY_SYSMAN_USB_STATUS, + (vconf_callback_fn) __usb_status_noti_handler); + vconf_ignore_key_changed(VCONFKEY_USB_CUR_MODE, + (vconf_callback_fn) __usb_mode_noti_handler); return; } diff --git a/src/dr-parser.c b/src/dr-parser.c index f47a0b2..034ff0a 100644 --- a/src/dr-parser.c +++ b/src/dr-parser.c @@ -43,16 +43,15 @@ const dr_at_cmd_t dr_at_cmds[] = { int _get_at_cmd_type(char *buf) { - if (buf == NULL) { + if (buf == NULL) return TOKEN_ERROR; - } int idx; for (idx = 0; dr_at_cmds[idx].at_cmd[0] != '\0'; idx++) { if (!g_ascii_strncasecmp - ((const gchar *)buf, (const gchar *)dr_at_cmds[idx].at_cmd, - strlen(dr_at_cmds[idx].at_cmd))) { + ((const gchar *)buf, (const gchar *)dr_at_cmds[idx].at_cmd, + strlen(dr_at_cmds[idx].at_cmd))) { DBG("Found %s\n", dr_at_cmds[idx].at_cmd); buf = buf + strlen(dr_at_cmds[idx].at_cmd); return dr_at_cmds[idx].token_type; diff --git a/src/dr-usb.c b/src/dr-usb.c index cf6ded4..ba0776b 100644 --- a/src/dr-usb.c +++ b/src/dr-usb.c @@ -111,12 +111,12 @@ static int __open_usb_node(void) return 0; failed: - if(usb_fd >= 0) { + if (usb_fd >= 0) close(usb_fd); - } - if(ctl_fd >= 0) { + + if (ctl_fd >= 0) close(ctl_fd); - } + return -1; } @@ -174,7 +174,7 @@ void _deinit_usb(void) { DBG("+\n"); int status; - if(dr_info.usb.thread_id <= 0) { + if (dr_info.usb.thread_id <= 0) { ERR("Invalid USB interface !!! \n"); return; } @@ -232,15 +232,15 @@ int _send_usb_line_state(int ctrl) static void __process_at_cmd(char *buffer, int nread) { - if(buffer == NULL || nread == 0) + if (buffer == NULL || nread == 0) return; int type; int check_cnt = 0; char *info = NULL; - DBG("Received: %s [%d byte]\n",buffer, nread); - if(TRUE == _is_exist_serial_session()) { + DBG("Received: %s [%d byte]\n", buffer, nread); + if (TRUE == _is_exist_serial_session()) { _write_to_serial_client(buffer, nread); return; } @@ -307,9 +307,9 @@ static void *__usb_monitor_thread(void *arg) sizeof(dr_info.usb.data_buffer)-1); if (nread < 0) { ERR("read length is less then zero\n"); - if (errno == EINTR) { + if (errno == EINTR) continue; - } + perror("Read USB failed"); __close_usb_node(); pthread_exit(NULL); @@ -333,9 +333,9 @@ static void *__usb_monitor_thread(void *arg) &line_state, sizeof(unsigned int)); if (ret < 0) { ERR("read length is less then zero\n"); - if (errno == EINTR) { + if (errno == EINTR) continue; - } + __close_usb_node(); pthread_exit(NULL); } @@ -343,11 +343,11 @@ static void *__usb_monitor_thread(void *arg) if ((line_state & ACM_CTRL_DTR) && (dr_info.line.input_line_state.bits.dtr == FALSE)) { DBG("ACM_CTRL_DTR+ received\n"); - if(dr_info.line.output_line_state.bits.dsr == FALSE) { - /* - * When USB initialized, DTR On is set to CP. - * If DR set DTR ON twice, Modem will be reponse as DSR Off - */ + if (dr_info.line.output_line_state.bits.dsr == FALSE) { + /* + * When USB initialized, DTR On is set to CP. + * If DR set DTR ON twice, Modem will be reponse as DSR Off + */ _send_dtr_ctrl_signal(DTR_ON); } dr_info.line.input_line_state.bits.dtr = TRUE; @@ -369,11 +369,11 @@ static void *__usb_monitor_thread(void *arg) __close_usb_node(); pthread_exit(NULL); } - } - else if (poll_state == 0) + } else if (poll_state == 0) { ERR("poll timeout\n"); - else if (poll_state < 0) + } else if (poll_state < 0) { ERR("poll error\n"); + } } return NULL; } diff --git a/src/dr-util.c b/src/dr-util.c index db8a7d5..a95f0bd 100644 --- a/src/dr-util.c +++ b/src/dr-util.c @@ -90,7 +90,7 @@ int _system_cmd_ext(const char *cmd, char *const arg_list[]) case 0: pid2 = fork(); - if(pid2 == 0) { + if (pid2 == 0) { execv(cmd, arg_list); exit(256); } else