Fixes for issues reported by Static Code Analysis 39/58439/1
authorshingil.kang <shingil.kang@samsung.com>
Mon, 16 Nov 2015 12:05:24 +0000 (21:05 +0900)
committershingil.kang <shingil.kang@samsung.com>
Mon, 1 Feb 2016 05:12:28 +0000 (14:12 +0900)
- Variable atomicity
- Bad sizeof usage

Change-Id: I07f780ad12be2e74176965cabaa1a810ef0893da
Signed-off-by: shingil.kang <shingil.kang@samsung.com>
src/transport.c

index e63e5d6..c4b64d7 100644 (file)
@@ -170,7 +170,7 @@ static int
 write_packet(int  fd, const char* name, apacket** ppacket)
 {
     char *p = (char*) ppacket;  /* we really write the packet address */
-    int r, len = sizeof(ppacket);
+    int r, len = sizeof(apacket*);
     char buff[8];
     if (!name) {
         snprintf(buff, sizeof buff, "fd=%d", fd);
@@ -182,7 +182,6 @@ write_packet(int  fd, const char* name, apacket** ppacket)
         dump_packet(name, "to remote", *ppacket);
     }
 #endif
-    len = sizeof(ppacket);
     while(len > 0) {
         r = sdb_write(fd, p, len);
         if(r > 0) {
@@ -748,7 +747,6 @@ atransport *acquire_one_transport(int state, transport_type ttype, const char* s
     atransport *result = NULL;
     int ambiguous = 0;
 
-retry:
     if (error_out)
         *error_out = "device not found";
 
@@ -797,7 +795,6 @@ retry:
             }
         }
     }
-    sdb_mutex_unlock(&transport_lock);
 
     if (result) {
          /* offline devices are ignored -- they are either being born or dying */
@@ -818,11 +815,9 @@ retry:
         /* found one that we can take */
         if (error_out)
             *error_out = NULL;
-    } else if (state != CS_ANY && (serial || !ambiguous)) {
-        sdb_sleep_ms(1000);
-        goto retry;
     }
 
+    sdb_mutex_unlock(&transport_lock);
     return result;
 }