Fix build warnings 20/274320/1 submit/tizen_6.5/20220426.081231
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 17 Jan 2022 05:17:58 +0000 (14:17 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 26 Apr 2022 07:36:08 +0000 (07:36 +0000)
Change-Id: Ib5784f64fb176d2916f376ca4c0ca05d6e363c36
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
(cherry picked from commit 61dbc6b6e81fb35432bfd17960cb04433a5628cf)

src/libcommon/ini-parser.c
tests/libcommon/test-common.c

index a82192c2cf26aab0185f4d2140a3f55394742a73..f08b28a2660b40f9fd63acfe108d12cd63cca702 100644 (file)
@@ -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);
                        }
                }
index 76e770c4736be96355594e5416f384bb93d7e22d..392830acc10396332c437ec6f4d550cd90c189dc 100644 (file)
@@ -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);
        }
 }