Removed Compilation warning - Unused return value 60/33160/2
authorAnkur <ankur29.garg@samsung.com>
Tue, 6 Jan 2015 12:09:48 +0000 (17:39 +0530)
committerKibak Yoon <kibak.yoon@samsung.com>
Wed, 7 Jan 2015 12:54:26 +0000 (04:54 -0800)
-Return value from the function call to write() was not being used, generating a compilation warning.
-Added a while loop to check how many bytes are written in each iteration and ensure that the whole buffer is written.

Change-Id: Ice225aa6cfd4eb36293e5475c1d37ebf672e633a

src/shared/common.cpp

index 9c6da31..884bbf3 100755 (executable)
@@ -50,7 +50,13 @@ EXTAPI void sf_log(int type , int priority , const char *tag , const char *fmt ,
                        sf_debug_file_fd = open(SF_SERVER_MSG_LOG_FILE, O_WRONLY|O_CREAT|O_APPEND, 0644);
                        if (sf_debug_file_fd != -1) {
                                vsnprintf(sf_debug_file_buf,255, fmt , ap );
-                               write(sf_debug_file_fd, sf_debug_file_buf, strlen(sf_debug_file_buf));
+                               int total_bytes_written = 0;
+                               while (total_bytes_written < (int) strlen(sf_debug_file_buf)){
+                                       int bytes_written = write(sf_debug_file_fd, (sf_debug_file_buf + total_bytes_written), strlen(sf_debug_file_buf) - total_bytes_written);
+                                       if (bytes_written == -1)
+                                               break;
+                                       total_bytes_written = total_bytes_written + bytes_written;
+                               }
                                close(sf_debug_file_fd);
                        }
                        break;