From: Youngjae Cho Date: Mon, 17 Jan 2022 05:17:58 +0000 (+0900) Subject: Fix build warnings X-Git-Tag: submit/tizen/20220525.001052~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61dbc6b6e81fb35432bfd17960cb04433a5628cf;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git Fix build warnings Change-Id: Ib5784f64fb176d2916f376ca4c0ca05d6e363c36 Signed-off-by: Youngjae Cho --- diff --git a/src/libcommon/ini-parser.c b/src/libcommon/ini-parser.c index a82192c..f08b28a 100644 --- a/src/libcommon/ini-parser.c +++ b/src/libcommon/ini-parser.c @@ -197,8 +197,10 @@ int libsys_config_parse_by_section(const char *fname, int cb(const struct parse_ prop = calloc(1, sizeof(struct section_property)); if (!prop) continue; - strncpy(prop->key, tmp_key, sizeof(prop->key) - 1); - strncpy(prop->value, tmp_value, sizeof(prop->value) - 1); + /* to suppress build warning of strncpy(-Wstringop-truncation), + * use memcpy instead. */ + memcpy(prop->key, tmp_key, sizeof(prop->key) - 1); + memcpy(prop->value, tmp_value, sizeof(prop->value) - 1); result.props = g_list_append(result.props, prop); } } diff --git a/tests/libcommon/test-common.c b/tests/libcommon/test-common.c index 76e770c..392830a 100644 --- a/tests/libcommon/test-common.c +++ b/tests/libcommon/test-common.c @@ -121,7 +121,7 @@ static void test_list_append_p(void **state) i = 0; SYS_G_LIST_FOREACH(head, elem, elem2) { - value = (int) elem2; + value = (int)(intptr_t) elem2; assert_int_equal(value, i++); } } @@ -142,7 +142,7 @@ static void test_list_prepend_p(void **state) i = 10; SYS_G_LIST_FOREACH(head, elem, elem2) { - value = (int) elem2; + value = (int)(intptr_t) elem2; assert_int_equal(value, --i); } }