On (16/01/14 19:22), Dmitri Pal wrote: >On 01/13/2014 06:00 AM, Lukas Slebodnik wrote: >> ehlo, >> >> Attached patches fix warnings with compiler flag Wmissing-prototypes. >> In my opinion, it is better declare function with static modifier if function >> is not part of public API. >> >> patch 0002-Use-static-modifier-for-unit-test-functions.patch helps me find >> out >> that negative_test was not execupted as part of INI unit tests. >> >> 0004-REFARRAY-Move-declaration-of-ref_array_debug-to-priv.patch >> It is better to have declaration in private header file, beacuse it prevents >> copy&paste errors. Declaration in file ini/ini_valueobj_ut.c was wrong. >> >> The last patch enables extra compiler warnings including Wmissing-prototypes. >> >> LS >> >> >> _______________________________________________ >> sssd-devel mailing list >> sssd-devel@lists.fedorahosted.org >> https://lists.fedorahosted.org/mailman/listinfo/sssd-devel >I looked at the patches again. They seem fine. >I looks like collection has all the debug functions already exposed and >public. > >Let us make ref_array_debug public too as is. If it changes we will add >a different function. So far I do not see a reason for it to change. > >Does this simplify things? >
I made ref_array_debug function public. Patch set is attached. but only 4th patch was changed. LS
>From 1da5c5af40bd499cc61aed1fd50a9a7f4317cb25 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Fri, 10 Jan 2014 21:29:39 +0100 Subject: [PATCH 1/5] INI: Use static modifier for non public functions Some functions (ini_comment_cb, ini_boundary_cb, is_just_spaces, is_allowed_spaces, parser_run, read_line) weren't declared in public header files and they weren't defined with static modifier. This patch fix it. --- ini/ini_comment.c | 6 +++--- ini/ini_config.c | 12 ++++++------ ini/ini_configobj.c | 14 +++++++------- ini/ini_parse.c | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ini/ini_comment.c b/ini/ini_comment.c index 53a84f8d0779dab391d66fd6b424f1d0454001e6..fc10b4f302042f89b373bb5a6d588bc438a68f70 100644 --- a/ini/ini_comment.c +++ b/ini/ini_comment.c @@ -82,9 +82,9 @@ void ini_comment_destroy(struct ini_comment *ic) /* Cleanup callback */ -void ini_comment_cb(void *elem, - ref_array_del_enum type, - void *data) +static void ini_comment_cb(void *elem, + ref_array_del_enum type, + void *data) { TRACE_FLOW_ENTRY(); diff --git a/ini/ini_config.c b/ini/ini_config.c index c0a908bb516f960db98adbbea962b9542250bb38..d46f2f8ffdfb89abad3c36bbf042ad6f247156da 100644 --- a/ini/ini_config.c +++ b/ini/ini_config.c @@ -36,12 +36,12 @@ /* Temporarily move the parsing function here */ /* THIS FUNCTION WILL BE REMOVED AS SOON AS WE SWITCH TO THE NEW INTERFACE */ /* Reads a line from the file */ -int read_line(FILE *file, - char *buf, - int read_size, - char **key, char **value, - int *length, - int *ext_error) +static int read_line(FILE *file, + char *buf, + int read_size, + char **key, char **value, + int *length, + int *ext_error) { char *res; diff --git a/ini/ini_configobj.c b/ini/ini_configobj.c index 603aaf421147fd0b01d057763b7eb544aafc37d6..8ae5ea707693959770bfb7b8f659c24cf5cfa4ce 100644 --- a/ini/ini_configobj.c +++ b/ini/ini_configobj.c @@ -173,13 +173,13 @@ int ini_config_create(struct ini_cfgobj **ini_config) } /* Callback to set the boundary */ -int ini_boundary_cb(const char *property, - int property_len, - int type, - void *data, - int length, - void *custom_data, - int *dummy) +static int ini_boundary_cb(const char *property, + int property_len, + int type, + void *data, + int length, + void *custom_data, + int *dummy) { int error = EOK; struct value_obj *vo = NULL; diff --git a/ini/ini_parse.c b/ini/ini_parse.c index 78d030e87cd0ef86588e6fd0db1a9e1294c402c2..7792324aaac1652c0c99bbe1f3ea52e9a68669d8 100644 --- a/ini/ini_parse.c +++ b/ini/ini_parse.c @@ -110,7 +110,7 @@ static int save_error(struct collection_item *el, const char *err_txt); -int is_just_spaces(const char *str, uint32_t len) +static int is_just_spaces(const char *str, uint32_t len) { uint32_t i; @@ -132,10 +132,10 @@ int is_just_spaces(const char *str, uint32_t len) * the line is OK too. * Any other character will cause an error. */ -int is_allowed_spaces(const char *str, - uint32_t len, - uint32_t parse_flags, - int *error) +static int is_allowed_spaces(const char *str, + uint32_t len, + uint32_t parse_flags, + int *error) { uint32_t i; int line_ok = 1; @@ -1602,7 +1602,7 @@ static int parser_error(struct parser_obj *po) /* Run parser */ -int parser_run(struct parser_obj *po) +static int parser_run(struct parser_obj *po) { int error = EOK; struct collection_item *item = NULL; -- 1.8.4.2
>From a30786b292bd3cefda33fc5bf24700af6beca494 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Sat, 11 Jan 2014 15:08:10 +0100 Subject: [PATCH 2/5] 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.4.2
>From cc42f4c7038e7032ba048cbeb259c5ec5a3a71c0 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Sat, 11 Jan 2014 15:18:40 +0100 Subject: [PATCH 3/5] INI: Fix warning missing-prototypes with experimental functions --- ini/ini_print.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ini/ini_print.c b/ini/ini_print.c index 4df934c5aa414f85c0f8e322f9b88fe09aaa8c8a..ad102361186e5c122b0c01c1b5335139e56f9e73 100644 --- a/ini/ini_print.c +++ b/ini/ini_print.c @@ -338,11 +338,13 @@ void print_file_parsing_errors(FILE *file, } +void print_grammar_errors(FILE *file, + struct collection_item *error_list); /* Print errors and warnings that were detected while processing grammar. * * The following doxygen description is moved here. * When the function gets exposed move it into - * the header file. + * the header file and remove prototype from this file. */ /** * @brief Print errors and warnings that were detected while @@ -367,11 +369,13 @@ void print_grammar_errors(FILE *file, INI_FAMILY_GRAMMAR); } +void print_validation_errors(FILE *file, + struct collection_item *error_list); /* Print errors and warnings that were detected while validating INI file. * * The following doxygen description is moved here. * When the function gets exposed move it into - * the header file. + * the header file and remove prototype from this file. */ /** * @brief Print errors and warnings that were detected while -- 1.8.4.2
>From 50c3969b7e7061a2e21fb1d2a765eb1e57ce8b81 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Sat, 11 Jan 2014 15:42:01 +0100 Subject: [PATCH 4/5] REFARRAY: Move declaration of ref_array_debug to public header file --- ini/ini_valueobj.c | 2 -- ini/ini_valueobj_ut.c | 3 --- refarray/ref_array.h | 16 ++++++++++++++++ refarray/ref_array_ut.c | 2 -- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ini/ini_valueobj.c b/ini/ini_valueobj.c index 20e61cd3f291aea076a16f35bec1bcd143656356..02d064323f84a18f274c1f95f0f975c51fda63de 100644 --- a/ini/ini_valueobj.c +++ b/ini/ini_valueobj.c @@ -1063,8 +1063,6 @@ int value_serialize(struct value_obj *vo, #ifdef HAVE_TRACE -extern void ref_array_debug(struct ref_array *ra, int num); - ref_array_debug(vo->raw_lines, 0); ref_array_debug(vo->raw_lengths, 1); #endif diff --git a/ini/ini_valueobj_ut.c b/ini/ini_valueobj_ut.c index 62ee9846a6be6cf4ea83b974576005170cb7c2fb..0a61069d50cecd430551539ddd4a9e07981fe2c8 100644 --- a/ini/ini_valueobj_ut.c +++ b/ini/ini_valueobj_ut.c @@ -42,9 +42,6 @@ int verbose = 0; typedef int (*test_fn)(void); - -extern void ref_array_debug(struct ref_array *ra); - static int create_comment(int i, struct ini_comment **ic) { int error = EOK; diff --git a/refarray/ref_array.h b/refarray/ref_array.h index d271d38b48b458ebf469f1387ef8e0679c8fa757..48e43075781f91107ef3f1489609b0166410fadd 100644 --- a/refarray/ref_array.h +++ b/refarray/ref_array.h @@ -363,6 +363,22 @@ int ref_array_copy(struct ref_array *ra, struct ref_array **copy_ra); + +/** + * @brief Print array for debugging purposes. + * + * Prints array internals. + * + * @param[in] ra Existing array object. + * @param[in] num If num is 0 elements will be printed as strings. + * If num is greater than 0 elements will be printed as + * decimal numbers. Otherwise element will not be + * interpreted in concrete way. + * + * No return value. + */ +void ref_array_debug(struct ref_array *ra, int num); + /** * @} */ diff --git a/refarray/ref_array_ut.c b/refarray/ref_array_ut.c index 5df089fbf878150dcb0812af800417f6abc114a2..5ce81a72c3c6d4e8c92d1b1ab72716a83b65cc34 100644 --- a/refarray/ref_array_ut.c +++ b/refarray/ref_array_ut.c @@ -35,8 +35,6 @@ int verbose = 0; if (verbose) foo; \ } while(0) -extern void ref_array_debug(struct ref_array *ra, int num); - typedef int (*test_fn)(void); /* Basic test */ -- 1.8.4.2
>From a9ded722fdb497550cb38a8e5994d0cd92fe67f7 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Sat, 11 Jan 2014 15:48:31 +0100 Subject: [PATCH 5/5] Enable extra compiler warning flags --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index e931e2a6dee44c5413cad6c87d6ef0339c57ead1..cac8702442fe39751b9c13f35d550e6065ad12c2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,8 @@ AM_CFLAGS = if HAVE_GCC AM_CFLAGS += \ -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual \ - -Wcast-align -Wwrite-strings + -Wcast-align -Wwrite-strings -Wextra -Wno-unused-parameter \ + -Wno-sign-compare -Wformat-security -Wmissing-prototypes endif AM_CPPFLAGS = \ -- 1.8.4.2
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel