diff options
author | Dmitri Pal <dpal@redhat.com> | 2012-12-23 16:13:14 -0500 |
---|---|---|
committer | Ondrej Kos <okos@redhat.com> | 2013-01-07 09:24:26 +0100 |
commit | 75fb29de5f180ff7a672865629c83367c10ae5ee (patch) | |
tree | fc807fdb512b4dbc74db461c320efc3787e5ef19 | |
parent | e984e914b6aced5dabe250ad769c63186f21f8b8 (diff) | |
download | ding-libs-75fb29de5f180ff7a672865629c83367c10ae5ee.tar.gz ding-libs-75fb29de5f180ff7a672865629c83367c10ae5ee.tar.xz ding-libs-75fb29de5f180ff7a672865629c83367c10ae5ee.zip |
Fix CLANG errors in unit test
-rw-r--r-- | collection/collection_ut.c | 9 | ||||
-rw-r--r-- | ini/ini_config_ut.c | 5 | ||||
-rw-r--r-- | ini/ini_parse_ut.c | 9 | ||||
-rw-r--r-- | ini/ini_valueobj_ut.c | 2 | ||||
-rw-r--r-- | path_utils/path_utils_ut.c | 59 |
5 files changed, 44 insertions, 40 deletions
diff --git a/collection/collection_ut.c b/collection/collection_ut.c index 1b48fc0..c34cd36 100644 --- a/collection/collection_ut.c +++ b/collection/collection_ut.c @@ -1648,7 +1648,6 @@ int search_test(void) } found = 0; - error = 0; error = col_is_item_in_collection(level1, "level1!level2!level3!level4!id", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT, &found); if ((error) || (!found)) { col_destroy_collection(level1); @@ -1662,7 +1661,6 @@ int search_test(void) found = 0; - error = 0; error = col_is_item_in_collection(level1, NULL, COL_TYPE_INTEGER, COL_TRAVERSE_DEFAULT, &found); if ((error) || (!found)) { col_destroy_collection(level1); @@ -1676,7 +1674,6 @@ int search_test(void) found = 0; - error = 0; error = col_is_item_in_collection(level1, "", COL_TYPE_INTEGER, COL_TRAVERSE_DEFAULT, &found); if ((error) || (!found)) { col_destroy_collection(level1); @@ -1690,7 +1687,6 @@ int search_test(void) found = 0; - error = 0; error = col_is_item_in_collection(level1, "level3!level4!id", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT, &found); if ((error) || (!found)) { col_destroy_collection(level1); @@ -1703,7 +1699,6 @@ int search_test(void) else COLOUT(printf("Expected item is found\n")); found = 0; - error = 0; error = col_is_item_in_collection(level1, "level3!packets", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT, &found); if ((error) || (!found)) { col_destroy_collection(level1); @@ -1716,7 +1711,6 @@ int search_test(void) else COLOUT(printf("Expected item is found\n")); found = 0; - error = 0; error = col_is_item_in_collection(level1, "level1!level2!stack", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT, &found); if ((error) || (!found)) { col_destroy_collection(level1); @@ -1729,7 +1723,6 @@ int search_test(void) else COLOUT(printf("Expected item is found\n")); found = 0; - error = 0; error = col_is_item_in_collection(level1, "level1!level2!level3", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT, &found); if ((error) || (!found)) { col_destroy_collection(level1); @@ -1743,7 +1736,6 @@ int search_test(void) /* Negative tests */ found = 0; - error = 0; error = col_is_item_in_collection(level1, NULL, 0, COL_TRAVERSE_DEFAULT, &found); if ((error != ENOENT) || (found)) { col_destroy_collection(level1); @@ -1762,7 +1754,6 @@ int search_test(void) else COLOUT(printf("No item is found as expected.\n")); found = 0; - error = 0; error = col_is_item_in_collection(level1, "", 0, COL_TRAVERSE_DEFAULT, &found); if ((error != ENOENT) || (found)) { col_destroy_collection(level1); diff --git a/ini/ini_config_ut.c b/ini/ini_config_ut.c index 362a941..ab0b1f7 100644 --- a/ini/ini_config_ut.c +++ b/ini/ini_config_ut.c @@ -467,7 +467,7 @@ int get_test(void) double number_double; unsigned number_unsigned; unsigned long number_ulong; - unsigned char logical; + unsigned char logical = 0; char *str; const char *cstr; const char *cstrn; @@ -637,7 +637,6 @@ int get_test(void) COLOUT(printf("Convert item to number without strict conversion.\n")); error = 0; - number = 1; number = get_int_config_value(item, 0, 10, &error); if (error) { /* We expected error in this case */ @@ -779,7 +778,7 @@ int get_test(void) error = 0; logical = get_bool_config_value(item, 1, &error); if (!error) { - printf("Expect error. Got success.\n"); + printf("Expect error. Got success. Value %d\n", (int) logical); free_ini_config(ini_config); return -1; } diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c index 61f8d5b..521c2f7 100644 --- a/ini/ini_parse_ut.c +++ b/ini/ini_parse_ut.c @@ -919,7 +919,7 @@ int merge_file_test(void) msecflags[i], m2flags[j], m1flags[j]); - INIOUT(printf(msg)); + INIOUT(printf("%s", msg)); error = simplebuffer_add_str(sbobj, msg, strlen(msg), @@ -948,7 +948,7 @@ int merge_file_test(void) msecflags[i], m2flags[j], m1flags[j]); - INIOUT(printf(msg)); + INIOUT(printf("%s", msg)); error = simplebuffer_add_str(sbobj, msg, strlen(msg), @@ -1353,7 +1353,7 @@ int get_test(void) double number_double; unsigned number_unsigned; unsigned long number_ulong; - unsigned char logical; + unsigned char logical = 0; char *str; const char *cstr; const char *cstrn; @@ -1579,7 +1579,6 @@ int get_test(void) INIOUT(printf("Convert value to number without strict conversion.\n")); error = 0; - number = 1; number = ini_get_int_config_value(vo, 0, 10, &error); if (error) { printf("Did not expect error.\n"); @@ -1723,7 +1722,7 @@ int get_test(void) error = 0; logical = ini_get_bool_config_value(vo, 1, &error); if (!error) { - printf("Expect error. Got success.\n"); + printf("Expect error. Got success. Value %d\n", (int) logical); ini_config_destroy(ini_config); return -1; } diff --git a/ini/ini_valueobj_ut.c b/ini/ini_valueobj_ut.c index 05f649b..a35b239 100644 --- a/ini/ini_valueobj_ut.c +++ b/ini/ini_valueobj_ut.c @@ -62,7 +62,7 @@ static int create_comment(int i, struct ini_comment **ic) (error = ini_comment_build(new_ic, "#This is the second line")) || (error = ini_comment_build(new_ic, ";This is the third line")) || (error = ini_comment_build(new_ic, ""))) { - printf("Failed to create comment object\n"); + printf("Failed to create comment object. Error %d.\n", error); ini_comment_destroy(new_ic); return -1; } diff --git a/path_utils/path_utils_ut.c b/path_utils/path_utils_ut.c index aadd89b..174e02d 100644 --- a/path_utils/path_utils_ut.c +++ b/path_utils/path_utils_ut.c @@ -380,53 +380,67 @@ START_TEST(test_split_path) array = split_path("/foo/bar", &n); fail_if(array == NULL); fail_unless(n == 3); - fail_unless_str_equal(array[0], "/"); - fail_unless_str_equal(array[1], "foo"); - fail_unless_str_equal(array[2], "bar"); - free(array); + if (array) { + fail_unless_str_equal(array[0], "/"); + fail_unless_str_equal(array[1], "foo"); + fail_unless_str_equal(array[2], "bar"); + free(array); + } array = split_path("/foo/../bar", &n); fail_if(array == NULL); fail_unless(n == 4); - fail_unless_str_equal(array[0], "/"); - fail_unless_str_equal(array[1], "foo"); - fail_unless_str_equal(array[2], ".."); - fail_unless_str_equal(array[3], "bar"); - free(array); + if (array) { + fail_unless_str_equal(array[0], "/"); + fail_unless_str_equal(array[1], "foo"); + fail_unless_str_equal(array[2], ".."); + fail_unless_str_equal(array[3], "bar"); + free(array); + } array = split_path("/foo/bar", NULL); fail_if(array == NULL); - fail_unless_str_equal(array[0], "/"); - fail_unless_str_equal(array[1], "foo"); - fail_unless_str_equal(array[2], "bar"); - free(array); + if (array) { + fail_unless_str_equal(array[0], "/"); + fail_unless_str_equal(array[1], "foo"); + fail_unless_str_equal(array[2], "bar"); + free(array); + } array = split_path("foo/bar", &n); fail_if(array == NULL); fail_unless(n == 2); - fail_unless_str_equal(array[0], "foo"); - fail_unless_str_equal(array[1], "bar"); - free(array); + if (array) { + fail_unless_str_equal(array[0], "foo"); + fail_unless_str_equal(array[1], "bar"); + free(array); + } array = split_path(".", &n); fail_if(array == NULL); fail_unless(n == 1); - fail_unless_str_equal(array[0], "."); - free(array); + if (array) { + fail_unless_str_equal(array[0], "."); + free(array); + } array = split_path("foo", &n); fail_if(array == NULL); fail_unless(n == 1); - fail_unless_str_equal(array[0], "foo"); - free(array); + if (array) { + fail_unless_str_equal(array[0], "foo"); + free(array); + } /* one might expect { "" } or outright NULL, but we agreed not to * do changes beyond bugfixes at this point */ array = split_path("", &n); fail_if(array == NULL); fail_unless(n == 0); - fail_unless(array[0] == NULL); - free(array); + if (array) { + fail_unless(array[0] == NULL); + free(array); + } } END_TEST @@ -573,6 +587,7 @@ void setup_directory_list(void) s = strdup(DIR_TEMPLATE); fail_unless(s != NULL, "strdup failed\n"); + if (!s) return; dlist_dir = mkdtemp(s); fail_unless(dlist_dir != NULL, "mkstemp failed [%d][%s]", errno, strerror(errno)); |