fix build warning and invalid coding rule 49/152249/2 accepted/tizen/unified/20171013.193102 submit/tizen/20171013.001308
authorYoungjae Shin <yj99.shin@samsung.com>
Mon, 25 Sep 2017 10:40:38 +0000 (19:40 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Mon, 25 Sep 2017 11:50:57 +0000 (20:50 +0900)
Change-Id: I3f00cfc5db6ae1b9084aaec38ff35ae3d95c2432
Signed-off-by: Youngjae Shin <yj99.shin@samsung.com>
include/dr-ipc.h
include/dr-main.h
include/dr-parser.h
include/dr-usb.h
include/dr-util.h
src/dr-ipc.c
src/dr-main.c
src/dr-noti-handler.c
src/dr-parser.c
src/dr-usb.c
src/dr-util.c

index 7708ff7a1f4a3005ede03cefe7d6ef624673744a..a5d9842d256a40d486d9c89f8fa73fae2f927e79 100644 (file)
@@ -23,7 +23,7 @@
 
 
 #ifndef _DR_IPC_H
-#define  _DR_IPC_H
+#define _DR_IPC_H
 
 #include <glib.h>
 
index 37399c9a1aa0b47dc587b73e071a057b17d3b9f5..3612717d6d27ae56751950d0c3a8fc8a7b1e628d 100644 (file)
 
 
 
-/** 
 * @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
 
index d6a609e7521386e09f44d976d268e241d9f1b3f5..ed58857ca292c0a20c536e765dfd059ec830ccdc 100644 (file)
@@ -38,4 +38,4 @@ enum {
 int _get_at_cmd_type(char *buf);
 
 
-#endif
+#endif //_DR_PARSER_H_
index d088e0e4a9d5476a9389d94667fc80cef289da8e..84e5416783769d8e72f969e5327c890c590f0630 100644 (file)
@@ -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);
 
 
index 69b1eb5fbc347feebd6591e2be97d492a7d61c1a..069ad3d6b5af4f730a666d9fe9b0e838cfe52659 100644 (file)
@@ -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_
index 99b5b33940c5e189ef2d5594ca73ae45602edec0..13e66a5dbb637b25c314862eecc9367e84b52986 100644 (file)
@@ -25,7 +25,6 @@
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib-bindings.h>
 #include <glib.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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)
index d425fe0d05853264be8acc1d4e216da10daddd46..6c6951b2ddbb6b1bae2a95311011d41b127aa49d 100755 (executable)
@@ -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();
index 0c8ce841d83e8313326c077d74fd6558ad34b8dd..a99e05dc58e554bc1588a737c49a4a5344c2c337 100755 (executable)
@@ -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;
 }
 
index f47a0b21d49a81cd8f9a4900218810fcde770be6..034ff0a86e3d488aafd7f8aa90d6554b6d93fa3a 100644 (file)
@@ -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;
index cf6ded4d7a9113324ae1943077799a5a7f9ba2fc..ba0776b31c2440ab622c0096851dbf593dcb90d7 100644 (file)
@@ -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;
 }
index db8a7d50fcd23d80051379ada291b49c51bf1ba5..a95f0bd0b0abe5b48182f7e6a70e4d543b031d7c 100644 (file)
@@ -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