[Tizen 6.0] Enabled build with -Wstringop-truncation, -Wimplicit-function-declaration sandbox/mkashkarov/tizen_6.0_build
authorMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Fri, 20 Dec 2019 12:51:48 +0000 (15:51 +0300)
committerMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Fri, 20 Dec 2019 13:00:52 +0000 (16:00 +0300)
src/main.c:68:3: error: 'strncpy' output truncated before terminating nul
copying 7 bytes from a string of the same length [-Werror=stringop-truncation]
   68 |   strncpy(process_name, "Unknown", strlen("Unknown"));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/orchestration_client.c:38:22: warning: implicit declaration of function
'getpid' [-Wimplicit-function-declaration]
   38 |     int client_pid = getpid();
      |                      ^~~~~~

CMain/src/main.c
libedge-orchestration/src/orchestration_client.c

index 09d8c95baf127e323b3ead0969399a53fdbcfa0d..d11011a07163a6ef82df63ea81397f95956e613f 100644 (file)
@@ -65,7 +65,7 @@ int request_cb(char* app_name, bool self_select, RequestServiceInfo service_info
 
        if (get_process_name_by_pid(process_name, client_pid) != 0) {
                DEBUG("could not get Process name");
-               strncpy(process_name, "Unknown", strlen("Unknown"));
+               strncpy(process_name, "Unknown", sizeof(process_name) - 1);
        }
 
        DEBUG("[orchestration_server]\n")
index 8db5e5b8b0272777788ca235efb672e235e93c2d..99f046af6c429c934dcc1f7b4f18e8a727c007f8 100755 (executable)
@@ -18,6 +18,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 #include <dbus_consumer.h>
 
 /* ---------------------------------------------------------------------------------------------------- */