>From cdb1f14d08e94e447866cbae81ceb0fbd2d61fe2 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 11 Jan 2014 15:08:10 +0100 Subject: [PATCH 2/7] Use static modifier for unit test functions This change fixes compiler warnings: warning: no previous prototype for 'function_abc' [-Wmissing-prototypes] --- basicobjects/simplebuffer_ut.c | 2 +- collection/collection_queue_ut.c | 4 ++-- collection/collection_stack_ut.c | 2 +- collection/collection_ut.c | 36 ++++++++++++++-------------- dhash/examples/dhash_example.c | 10 +++++--- dhash/examples/dhash_test.c | 13 +++++----- ini/ini_comment_ut.c | 8 +++---- ini/ini_config_ut.c | 16 ++++++------- ini/ini_parse_ut.c | 52 ++++++++++++++++++++-------------------- ini/ini_valueobj_ut.c | 14 +++++------ path_utils/path_utils_ut.c | 20 +++++++++------- refarray/ref_array_ut.c | 20 ++++++++-------- 12 files changed, 102 insertions(+), 95 deletions(-) diff --git a/basicobjects/simplebuffer_ut.c b/basicobjects/simplebuffer_ut.c index ba9d172856262fe9ca34abf0dd702c1d305544c9..7b90d261979e49298996d5608635c933ed501f88 100644 --- a/basicobjects/simplebuffer_ut.c +++ b/basicobjects/simplebuffer_ut.c @@ -37,7 +37,7 @@ int verbose = 0; } while(0) -int simple_test(void) +static int simple_test(void) { int error = EOK; struct simplebuffer *data = NULL; diff --git a/collection/collection_queue_ut.c b/collection/collection_queue_ut.c index c4f7a68b2b927fff5d89c26cbf896f20413824b2..4ba5cd0b2cfd07d57dedca584a4fdbbe44ebf9c4 100644 --- a/collection/collection_queue_ut.c +++ b/collection/collection_queue_ut.c @@ -37,7 +37,7 @@ int verbose = 0; } while(0) -int queue_test(void) +static int queue_test(void) { struct collection_item *queue = NULL; char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; @@ -96,7 +96,7 @@ int queue_test(void) } -int empty_test(void) +static int empty_test(void) { struct collection_item *queue = NULL; struct collection_item *item = NULL; diff --git a/collection/collection_stack_ut.c b/collection/collection_stack_ut.c index 9c25308fa878430f46fc7c84cf3500e3eb1b6086..57b4db886c8b748cb0baa0ec17cfab3f49bef450 100644 --- a/collection/collection_stack_ut.c +++ b/collection/collection_stack_ut.c @@ -38,7 +38,7 @@ int verbose = 0; -int stack_test(void) +static int stack_test(void) { struct collection_item *stack = NULL; char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; diff --git a/collection/collection_ut.c b/collection/collection_ut.c index 26928794fc737eb2d622275e1bcaef93323b52cd..965daf408bf91767ea45f070dc33eba6b08e560d 100644 --- a/collection/collection_ut.c +++ b/collection/collection_ut.c @@ -39,7 +39,7 @@ int verbose = 0; -int ref_collection_test(void) +static int ref_collection_test(void) { struct collection_item *peer = NULL; struct collection_item *socket = NULL; @@ -131,7 +131,7 @@ int ref_collection_test(void) } -int single_collection_test(void) +static int single_collection_test(void) { struct collection_item *handle = NULL; int error = EOK; @@ -192,7 +192,7 @@ int single_collection_test(void) return error; } -int add_collection_test(void) +static int add_collection_test(void) { struct collection_item *peer = NULL; struct collection_item *socket = NULL; @@ -250,9 +250,9 @@ int add_collection_test(void) return error; } -int copy_cb(struct collection_item *item, - void *ext_data, - int *skip) +static int copy_cb(struct collection_item *item, + void *ext_data, + int *skip) { COLOUT(printf("INSIDE Copy Callback\n")); COLOUT(col_debug_item(item)); @@ -262,7 +262,7 @@ int copy_cb(struct collection_item *item, } -int mixed_collection_test(void) +static int mixed_collection_test(void) { struct collection_item *peer; struct collection_item *socket1; @@ -643,7 +643,7 @@ int mixed_collection_test(void) } -int iterator_test(void) +static int iterator_test(void) { struct collection_item *peer = NULL; struct collection_item *initial = NULL; @@ -1341,7 +1341,7 @@ int iterator_test(void) } -int insert_extract_test(void) +static int insert_extract_test(void) { struct collection_item *col; struct collection_item *col2; @@ -1531,12 +1531,12 @@ int insert_extract_test(void) } /* Cleanup collback */ -void cb(const char *property, - int property_len, - int type, - void *data, - int length, - void *ext_data) +static void cb(const char *property, + int property_len, + int type, + void *data, + int length, + void *ext_data) { COLOUT(printf("%s\n", *((const char **)ext_data))); COLOUT(printf("Property: %s\n", property)); @@ -1545,7 +1545,7 @@ void cb(const char *property, COLOUT(printf("Data len: %d\n", length)); } -int delete_test(void) +static int delete_test(void) { struct collection_item *col; @@ -1605,7 +1605,7 @@ int delete_test(void) } /* Search test */ -int search_test(void) +static int search_test(void) { struct collection_item *level1 = NULL; struct collection_item *level2 = NULL; @@ -1782,7 +1782,7 @@ int search_test(void) } /* Sort test */ -int sort_test(void) +static int sort_test(void) { struct collection_item *level1 = NULL; struct collection_item *level2a = NULL; diff --git a/dhash/examples/dhash_example.c b/dhash/examples/dhash_example.c index c7eac3daae3780c2a19aa6f377e2342aad7be51e..d2095bd05a7e358ad644805b4221d130234facd3 100644 --- a/dhash/examples/dhash_example.c +++ b/dhash/examples/dhash_example.c @@ -29,12 +29,15 @@ struct my_data_t { char bar[128]; }; -void delete_callback(hash_entry_t *entry, hash_destroy_enum type, void *pvt) +static void delete_callback(hash_entry_t *entry, + hash_destroy_enum type, + void *pvt) { if (entry->value.type == HASH_VALUE_PTR) free(entry->value.ptr); } -bool visit_callback(hash_entry_t *entry, void *user_data) +static bool visit_callback(hash_entry_t *entry, + void *user_data) { unsigned long *count = (unsigned long *)user_data; struct my_data_t *my_data = (struct my_data_t *) entry->value.ptr; @@ -45,13 +48,14 @@ bool visit_callback(hash_entry_t *entry, void *user_data) return true; } -struct my_data_t *new_data(int foo, const char *bar) +static struct my_data_t *new_data(int foo, const char *bar) { struct my_data_t *my_data = malloc(sizeof(struct my_data_t)); my_data->foo = foo; strncpy(my_data->bar, bar, sizeof(my_data->bar)); return my_data; } + int main(int argc, char **argv) { static hash_table_t *table = NULL; diff --git a/dhash/examples/dhash_test.c b/dhash/examples/dhash_test.c index f57bc5270facd6f4e8dbef0db8ceda362da3c392..303e9f815ca8fb88446e2157251044439a404357 100644 --- a/dhash/examples/dhash_test.c +++ b/dhash/examples/dhash_test.c @@ -34,7 +34,7 @@ hash_entry_t *iter_result_2 = NULL; unsigned long max_test = DEFAULT_MAX_TEST; int verbose = 0; -const char *error_string(int error) +static const char *error_string(int error) { const char *str; @@ -53,7 +53,7 @@ const char *error_string(int error) return str; } -char *key_string(hash_key_t *key) +static char *key_string(hash_key_t *key) { static char buf[BUF_SIZE]; @@ -71,7 +71,7 @@ char *key_string(hash_key_t *key) return buf; } -char *value_string(hash_value_t *value) +static char *value_string(hash_value_t *value) { static char buf[BUF_SIZE]; @@ -108,7 +108,7 @@ char *value_string(hash_value_t *value) return buf; } -char *entry_string(hash_entry_t *entry) +static char *entry_string(hash_entry_t *entry) { static char buf[BUF_SIZE]; @@ -118,7 +118,7 @@ char *entry_string(hash_entry_t *entry) } -bool callback(hash_entry_t *item, void *user_data) +static bool callback(hash_entry_t *item, void *user_data) { unsigned long *callback_count = (unsigned long *)user_data; @@ -130,7 +130,8 @@ bool callback(hash_entry_t *item, void *user_data) return true; } -void delete_callback(hash_entry_t *item, hash_destroy_enum type, void *pvt) +static void delete_callback(hash_entry_t *item, hash_destroy_enum type, + void *pvt) { if (item->value.type == HASH_VALUE_PTR) free(item->value.ptr); } diff --git a/ini/ini_comment_ut.c b/ini/ini_comment_ut.c index eb463600c3d6d30204b3eea83a0a0d28fa80d83a..d45e5d70919870fb37d7246316efc225e3ad6aca 100644 --- a/ini/ini_comment_ut.c +++ b/ini/ini_comment_ut.c @@ -36,7 +36,7 @@ int verbose = 0; typedef int (*test_fn)(void); -int file_test(void) +static int file_test(void) { int error = EOK; struct ini_comment *ic = NULL; @@ -60,7 +60,7 @@ int file_test(void) } -int alter_test(void) +static int alter_test(void) { int error = EOK; struct ini_comment *ic = NULL; @@ -158,7 +158,7 @@ int alter_test(void) return error; } -int copy_test(void) +static int copy_test(void) { int error = EOK; struct ini_comment *ic = NULL; @@ -233,7 +233,7 @@ int copy_test(void) return error; } -int add_test(void) +static int add_test(void) { int error = EOK; struct ini_comment *ic = NULL; diff --git a/ini/ini_config_ut.c b/ini/ini_config_ut.c index fff3c4e920e703cef19a52407984f1c288d737f4..cd0354b9782f90d9c8f09b4ad6c7895c04d9c3dd 100644 --- a/ini/ini_config_ut.c +++ b/ini/ini_config_ut.c @@ -42,7 +42,7 @@ int verbose = 0; } while(0) -int basic_test(void) +static int basic_test(void) { int error; struct collection_item *ini_config = NULL; @@ -84,7 +84,7 @@ int basic_test(void) return 0; } -int single_file(void) +static int single_file(void) { int error; struct collection_item *ini_config = NULL; @@ -189,7 +189,7 @@ int single_file(void) return 0; } -int single_fd(void) +static int single_fd(void) { int error; struct collection_item *ini_config = NULL; @@ -306,7 +306,7 @@ int single_fd(void) return 0; } -int negative_test(void) +static int negative_test(void) { int error; unsigned int count; @@ -374,7 +374,7 @@ int negative_test(void) } -int real_test(const char *file) +static int real_test(const char *file) { int error; struct collection_item *ini_config = NULL; @@ -456,7 +456,7 @@ int real_test(const char *file) return 0; } -int get_test(void) +static int get_test(void) { int error; @@ -1298,7 +1298,7 @@ int get_test(void) * and one needs to parse the configuration file * for the first time and load configuration */ -int startup_test(void) +static int startup_test(void) { int error; struct collection_item *ini_config = NULL; @@ -1417,7 +1417,7 @@ int startup_test(void) return 0; } -int reload_test(void) +static int reload_test(void) { int error; diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c index 33019b2b934779b71b11fc3dc7dbc2bbbedc5539..1fa26249073db9e1dc1e39340ba0afa73b559540 100644 --- a/ini/ini_parse_ut.c +++ b/ini/ini_parse_ut.c @@ -48,9 +48,9 @@ char *confdir = NULL; typedef int (*test_fn)(void); -int test_one_file(const char *in_filename, - const char *out_filename, - int edge) +static int test_one_file(const char *in_filename, + const char *out_filename, + int edge) { int error = EOK; struct ini_cfgfile *file_ctx = NULL; @@ -170,7 +170,7 @@ int test_one_file(const char *in_filename, /* Run tests for multiple files */ -int read_save_test(void) +static int read_save_test(void) { int error = EOK; int i = 0; @@ -212,7 +212,7 @@ int read_save_test(void) } /* Run tests for multiple files */ -int read_again_test(void) +static int read_again_test(void) { int error = EOK; int i = 0; @@ -264,7 +264,7 @@ int read_again_test(void) return error; } -int create_expect(const char *checkname) +static int create_expect(const char *checkname) { FILE *ff; int error = EOK; @@ -333,7 +333,7 @@ int create_expect(const char *checkname) } /* Check merge modes */ -int merge_values_test(void) +static int merge_values_test(void) { int error = EOK; int i; @@ -493,7 +493,7 @@ int merge_values_test(void) } /* Check merge modes */ -int merge_section_test(void) +static int merge_section_test(void) { int error = EOK; int i, j; @@ -697,9 +697,9 @@ int merge_section_test(void) return error; } -int read_one_file(char *name, - struct ini_cfgobj *ini_config, - uint32_t collision_flags) +static int read_one_file(char *name, + struct ini_cfgobj *ini_config, + uint32_t collision_flags) { int error = EOK; struct ini_cfgfile *file_ctx = NULL; @@ -746,7 +746,7 @@ int read_one_file(char *name, } /* Check merge modes */ -int merge_file_test(void) +static int merge_file_test(void) { int error = EOK; int i, j; @@ -1067,7 +1067,7 @@ int merge_file_test(void) return EOK; } -int startup_test(void) +static int startup_test(void) { int error = EOK; struct ini_cfgfile *file_ctx = NULL; @@ -1235,7 +1235,7 @@ int startup_test(void) return 0; } -int reload_test(void) +static int reload_test(void) { int error = EOK; struct ini_cfgfile *file_ctx = NULL; @@ -1428,13 +1428,13 @@ int reload_test(void) return 0; } -int test_one_array(struct ini_cfgobj *ini_config, - const char *section, - const char *value, - int raw, - int expect, - const char *sep, - const char *message) +static int test_one_array(struct ini_cfgobj *ini_config, + const char *section, + const char *value, + int raw, + int expect, + const char *sep, + const char *message) { struct value_obj *vo = NULL; int error = 0; @@ -1496,7 +1496,7 @@ int test_one_array(struct ini_cfgobj *ini_config, return EOK; } -int get_test(void) +static int get_test(void) { int error; @@ -2782,7 +2782,7 @@ int get_test(void) return EOK; } -int space_test(void) +static int space_test(void) { int error; @@ -2866,7 +2866,7 @@ int space_test(void) } -int trim_test(void) +static int trim_test(void) { int error; struct ini_cfgfile *file_ctx = NULL; @@ -2965,7 +2965,7 @@ int trim_test(void) return EOK; } -int comment_test(void) +static int comment_test(void) { int error; struct ini_cfgfile *file_ctx = NULL; @@ -3030,7 +3030,7 @@ int comment_test(void) return EOK; } -void create_boms(void) +static void create_boms(void) { FILE *f; diff --git a/ini/ini_valueobj_ut.c b/ini/ini_valueobj_ut.c index 9ab960ffcf2914b73e96598d1a2d760e9fa2d617..62ee9846a6be6cf4ea83b974576005170cb7c2fb 100644 --- a/ini/ini_valueobj_ut.c +++ b/ini/ini_valueobj_ut.c @@ -76,7 +76,7 @@ static int create_comment(int i, struct ini_comment **ic) /* Save value to the file */ /* NOTE: might be moved into the API in future */ -int save_value(FILE *ff, const char *key, struct value_obj *vo) +static int save_value(FILE *ff, const char *key, struct value_obj *vo) { int error = EOK; @@ -125,7 +125,7 @@ int save_value(FILE *ff, const char *key, struct value_obj *vo) } /* Test to create value object using arrays */ -int other_create_test(FILE *ff, struct value_obj **vo) +static int other_create_test(FILE *ff, struct value_obj **vo) { int error = EOK; struct value_obj *new_vo = NULL; @@ -338,7 +338,7 @@ int other_create_test(FILE *ff, struct value_obj **vo) } /* Modify the value object */ -int modify_test(FILE *ff, struct value_obj *vo) +static int modify_test(FILE *ff, struct value_obj *vo) { int error = EOK; const char *strval = "Domain100, Domain200, Domain300"; @@ -377,7 +377,7 @@ int modify_test(FILE *ff, struct value_obj *vo) } -int vo_basic_test(void) +static int vo_basic_test(void) { int error = EOK; const char *strvalue = "Test multi_word_value_that_will_" @@ -480,7 +480,7 @@ int vo_basic_test(void) return EOK; } -int vo_copy_test(void) +static int vo_copy_test(void) { int error = EOK; const char *strvalue = "Test multi word value that " @@ -623,13 +623,13 @@ int vo_copy_test(void) return EOK; } -int vo_show_test(void) +static int vo_show_test(void) { VOOUT(system("cat test.ini")); return EOK; } -int vo_mc_test(void) +static int vo_mc_test(void) { int error = EOK; struct value_obj *vo1 = NULL; diff --git a/path_utils/path_utils_ut.c b/path_utils/path_utils_ut.c index cdbdf33e171333fa10e5c462e6d955fe465b5bd6..27c99b617d2b83d6bba42d677aaa9bdbfed93a14 100644 --- a/path_utils/path_utils_ut.c +++ b/path_utils/path_utils_ut.c @@ -580,7 +580,7 @@ START_TEST(test_find_existing_directory_ancestor_neg) END_TEST /**** directory_list ****/ -void setup_directory_list(void) +static void setup_directory_list(void) { char *s = NULL; int ret; @@ -602,7 +602,7 @@ void setup_directory_list(void) fail_unless(ret != -1, "mkdir %s failed [%d][%s]", dlist_subsubdir, errno, strerror(errno)); } -void teardown_directory_list(void) +static void teardown_directory_list(void) { int ret; @@ -628,9 +628,11 @@ void teardown_directory_list(void) } } -bool dirlist_cb_nonrecursive(const char *directory, const char *base_name, - const char *path, struct stat *info, - void *user_data) +static bool dirlist_cb_nonrecursive(const char *directory, + const char *base_name, + const char *path, + struct stat *info, + void *user_data) { int *data = (int *) user_data; @@ -640,9 +642,9 @@ bool dirlist_cb_nonrecursive(const char *directory, const char *base_name, return true; } -bool dirlist_cb_recursive(const char *directory, const char *base_name, - const char *path, struct stat *info, - void *user_data) +static bool dirlist_cb_recursive(const char *directory, const char *base_name, + const char *path, struct stat *info, + void *user_data) { bool *seen_child = (bool *) user_data; static bool seen_parent = false; @@ -698,7 +700,7 @@ START_TEST(test_is_ancestor_path) END_TEST -Suite *path_utils_suite(void) +static Suite *path_utils_suite(void) { Suite *s = suite_create("path_utils"); diff --git a/refarray/ref_array_ut.c b/refarray/ref_array_ut.c index 343b7faa8862797306d836759ebc2b54bd61de2e..5df089fbf878150dcb0812af800417f6abc114a2 100644 --- a/refarray/ref_array_ut.c +++ b/refarray/ref_array_ut.c @@ -40,7 +40,7 @@ extern void ref_array_debug(struct ref_array *ra, int num); typedef int (*test_fn)(void); /* Basic test */ -int ref_array_basic_test(void) +static int ref_array_basic_test(void) { const char *line1 = "line1"; const char *line2 = "line2"; @@ -217,16 +217,16 @@ int ref_array_basic_test(void) return EOK; } -void array_cleanup(void *elem, - ref_array_del_enum type, - void *data) +static void array_cleanup(void *elem, + ref_array_del_enum type, + void *data) { RAOUT(printf("%s%s\n", (char *)data, *((char **)elem))); free(*((char **)elem)); } /* Free test */ -int ref_array_free_test(void) +static int ref_array_free_test(void) { const char *line1 = "line1"; const char *line2 = "line2"; @@ -308,7 +308,7 @@ int ref_array_free_test(void) return EOK; } -int ref_array_adv_test(void) +static int ref_array_adv_test(void) { int error = EOK; const char *lines[] = { "line0", @@ -559,8 +559,8 @@ int ref_array_adv_test(void) return EOK; } -int copy_cb(void *elem, - void *new_elem) +static int copy_cb(void *elem, + void *new_elem) { char *ne = NULL; @@ -573,7 +573,7 @@ int copy_cb(void *elem, return EOK; } -int ref_array_copy_test(void) +static int ref_array_copy_test(void) { const char *line1 = "line1"; const char *line2 = "line2"; @@ -686,7 +686,7 @@ int ref_array_copy_test(void) } -int ref_array_copy_num_test(void) +static int ref_array_copy_num_test(void) { uint32_t i,j,k; struct ref_array *ra; -- 1.8.5.3