From 9105a1e8ea5a692bcbf823e473a214e94a43bc49 Mon Sep 17 00:00:00 2001 From: Rong Tao Date: Fri, 20 May 2022 08:56:15 +0800 Subject: [PATCH] Fix warning of strncpy() size field. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bcc/tests/cc/test_c_api.cc:159:10: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 1024 equals destination size [-Wstringop-truncation] 159 | strncpy(libpath, lm->l_name, 1024); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ --- tests/cc/test_c_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cc/test_c_api.cc b/tests/cc/test_c_api.cc index e456840d1b45..eb56dc08e7a9 100644 --- a/tests/cc/test_c_api.cc +++ b/tests/cc/test_c_api.cc @@ -156,7 +156,7 @@ static int mntns_func(void *arg) { return -1; } - strncpy(libpath, lm->l_name, 1024); + strncpy(libpath, lm->l_name, sizeof(libpath) - 1); dlclose(dlhdl); dlhdl = NULL;