SDB: Fixed prevent issue 65/18365/2
authorshingil.kang <shingil.kang@samsung.com>
Fri, 21 Mar 2014 07:51:24 +0000 (16:51 +0900)
committershingil.kang <shingil.kang@samsung.com>
Thu, 27 Mar 2014 08:07:47 +0000 (17:07 +0900)
Checked return value

Change-Id: I652833172ee798bc28fdbbe7c0ee885c0f72e8d7
Signed-off-by: shingil.kang <shingil.kang@samsung.com>
src/fdevent.c
src/transport.c
src/usb_linux.c
src/utils_unix.c

index 1b238447c2f1cf35d1a30b052a1c5581dbcb3d0c..fbaf95487b4d2227ad622574826b3beafd8aa46e 100755 (executable)
@@ -91,7 +91,9 @@ void fdevent_install(FD_EVENT *fde, int fd, fd_func func, void *arg)
     fde->events = 0;
 
 #ifndef OS_WINDOWS
-    fcntl(fd, F_SETFL, O_NONBLOCK);
+    int ret = fcntl(fd, F_SETFL, O_NONBLOCK);
+    if(ret == -1)
+        fprintf(stderr, "fail to set the file status flag\n");
     if(fd >= max_select) {
         max_select = fd + 1;
     }
index d5e691c2c8afc14d8bd34c1d351443584c56b8e1..8e771a0f9293388722534387105e22e7547ba6a7 100755 (executable)
@@ -750,7 +750,10 @@ static int check_data(PACKET *p)
 void wakeup_select_func(int _fd, unsigned ev, void *data) {
     T_PACKET* t_packet = NULL;
 
-    readx(_fd, &t_packet, sizeof(t_packet));
+    int length = readx(_fd, &t_packet, sizeof(t_packet));
+    if(length == -1) {
+        LOG_DEBUG("wakeup_select_func(): cannot read FD(%d) transport packet", _fd);
+    }
 
     TRANSPORT* t= t_packet->t;
     D("T(%s)\n", t->serial);
index 6a73663c25cd9975f1c5f050a0d19698eae9a71b..fcba4e85d47fdc96dc6391ce1fcfa408ea214a3d 100644 (file)
@@ -454,7 +454,9 @@ static int usb_urb_transfer(usb_handle *h, int ep, char *bytes, int size,
          * then we need to reap it or else the next time we call this function,
          * we'll get the previous completion and exit early
          */
-        ioctl(h->node_fd, USBDEVFS_REAPURB, &context);
+        ret = ioctl(h->node_fd, USBDEVFS_REAPURB, &context);
+        if (ret < 0 && errno != EINVAL)
+            LOG_DEBUG("error reaping URB: %s\n", strerror(errno));
 
         return rc;
     }
index 3ae9d3b8fbba1edc1ab02e5800932ac92ad2a17f..aec8ad94f0f50d042a8ba2354fcc14a3e2afcfb6 100755 (executable)
@@ -144,7 +144,9 @@ static char* _ansi_to_utf8(const char *str)
 
 static void  _close_on_exec(int  fd)
 {
-    fcntl( fd, F_SETFD, FD_CLOEXEC );
+    int ret = fcntl( fd, F_SETFD, FD_CLOEXEC );
+    if (ret == -1)
+        fprintf(stderr, "fail to set the file descriptor to be closed when the process executes another program\n");
 }
 
 static int _sdb_open( const char*  pathname, int  options )
@@ -249,7 +251,9 @@ static int _sdb_socket_setbufsize( int   fd, int  bufsize )
 static void _disable_tcp_nagle(int fd)
 {
     int  on = 1;
-    setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on) );
+    int ret = setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on) );
+    if (ret == -1)
+       fprintf(stderr, "fail to set level option of FD(%d)", fd);
 }
 
 static int  _sdb_thread_create( sdb_thread_t  *pthread, sdb_thread_func_t  start, void*  arg )
@@ -338,7 +342,9 @@ static int _sdb_port_listen(uint32_t inet, int port, int type)
     }
 
     n = 1;
-    setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n));
+    int ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n));
+    if (ret == -1)
+       fprintf(stderr, "fail to set level option of FD(%d)", s);
 
     if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
         sdb_close(s);