From: Wouter Wijngaards Date: Wed, 7 Jul 2010 13:13:36 +0000 (+0000) Subject: - Neat function prototypes, unshadowed local declarations. X-Git-Tag: release-1.4.6rc1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f042f0dd5d70e0904e1a3c08189e5c09d05b3fd6;p=thirdparty%2Funbound.git - Neat function prototypes, unshadowed local declarations. git-svn-id: file:///svn/unbound/trunk@2188 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/acl_list.c b/daemon/acl_list.c index acc893a6c..48c8e0fe4 100644 --- a/daemon/acl_list.c +++ b/daemon/acl_list.c @@ -47,7 +47,7 @@ #include "util/net_help.h" struct acl_list* -acl_list_create() +acl_list_create(void) { struct acl_list* acl = (struct acl_list*)calloc(1, sizeof(struct acl_list)); diff --git a/daemon/acl_list.h b/daemon/acl_list.h index 47c4c5293..03ac301bf 100644 --- a/daemon/acl_list.h +++ b/daemon/acl_list.h @@ -89,7 +89,7 @@ struct acl_addr { * Create acl structure * @return new structure or NULL on error. */ -struct acl_list* acl_list_create(); +struct acl_list* acl_list_create(void); /** * Delete acl structure. diff --git a/daemon/daemon.c b/daemon/daemon.c index 6f22620ee..941324759 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -131,7 +131,7 @@ static RETSIGTYPE record_sigh(int sig) * Stores signals to replay later. */ static void -signal_handling_record() +signal_handling_record(void) { if( signal(SIGTERM, record_sigh) == SIG_ERR || #ifdef SIGQUIT @@ -169,7 +169,7 @@ signal_handling_playback(struct worker* wrk) } struct daemon* -daemon_init() +daemon_init(void) { struct daemon* daemon = (struct daemon*)calloc(1, sizeof(struct daemon)); @@ -276,7 +276,7 @@ static void daemon_setup_modules(struct daemon* daemon) * @param shufport: the portlist output. * @return number of ports available. */ -int daemon_get_shufport(struct daemon* daemon, int* shufport) +static int daemon_get_shufport(struct daemon* daemon, int* shufport) { int i, n, k, temp; int avail = 0; @@ -339,12 +339,13 @@ daemon_create_workers(struct daemon* daemon) free(shufport); } +#ifdef THREADS_DISABLED /** * Close all pipes except for the numbered thread. * @param daemon: daemon to close pipes in. * @param thr: thread number 0..num-1 of thread to skip. */ -void close_other_pipes(struct daemon* daemon, int thr) +static void close_other_pipes(struct daemon* daemon, int thr) { int i; for(i=0; inum; i++) @@ -359,6 +360,7 @@ void close_other_pipes(struct daemon* daemon, int thr) } } } +#endif /* THREADS_DISABLED */ /** * Function to start one thread. diff --git a/daemon/daemon.h b/daemon/daemon.h index c170eeda6..e0feaf59c 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -108,7 +108,7 @@ struct daemon { * Initialize daemon structure. * @return: The daemon structure, or NULL on error. */ -struct daemon* daemon_init(); +struct daemon* daemon_init(void); /** * Open shared listening ports (if needed). diff --git a/daemon/remote.c b/daemon/remote.c index 2d770d497..b9391499f 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -1618,7 +1618,7 @@ do_list_local_data(SSL* ssl, struct worker* worker) } /** tell other processes to execute the command */ -void +static void distribute_cmd(struct daemon_remote* rc, SSL* ssl, char* cmd) { int i; diff --git a/daemon/worker.c b/daemon/worker.c index c8df93389..210b20435 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -141,7 +141,7 @@ debug_total_mem(size_t calctotal) #endif /* UNBOUND_ALLOC_STATS */ /** Report on memory usage by this thread and global */ -void +static void worker_mem_report(struct worker* ATTR_UNUSED(worker), struct serviced_query* ATTR_UNUSED(cur_serv)) { diff --git a/doc/Changelog b/doc/Changelog index 9bd9d0a8f..1da8c683c 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +7 July 2010: Wouter + - Neat function prototypes, unshadowed local declarations. + 6 July 2010: Wouter - failure to chown the pidfile is not fatal any more. - testbound uses UTC timezone. diff --git a/iterator/iter_donotq.c b/iterator/iter_donotq.c index cc2930ec3..bd606335b 100644 --- a/iterator/iter_donotq.c +++ b/iterator/iter_donotq.c @@ -49,7 +49,7 @@ #include "util/net_help.h" struct iter_donotq* -donotq_create() +donotq_create(void) { struct iter_donotq* dq = (struct iter_donotq*)calloc(1, sizeof(struct iter_donotq)); diff --git a/iterator/iter_donotq.h b/iterator/iter_donotq.h index c90b0ab2a..4c4fcb289 100644 --- a/iterator/iter_donotq.h +++ b/iterator/iter_donotq.h @@ -65,7 +65,7 @@ struct iter_donotq { * Create donotqueryaddresses structure * @return new structure or NULL on error. */ -struct iter_donotq* donotq_create(); +struct iter_donotq* donotq_create(void); /** * Delete donotqueryaddresses structure. diff --git a/iterator/iter_fwd.c b/iterator/iter_fwd.c index c8b233915..4d3ff16a0 100644 --- a/iterator/iter_fwd.c +++ b/iterator/iter_fwd.c @@ -67,7 +67,7 @@ fwd_cmp(const void* k1, const void* k2) } struct iter_forwards* -forwards_create() +forwards_create(void) { struct iter_forwards* fwd = (struct iter_forwards*)calloc(1, sizeof(struct iter_forwards)); diff --git a/iterator/iter_fwd.h b/iterator/iter_fwd.h index ea7bd22a1..8f3bc1fa2 100644 --- a/iterator/iter_fwd.h +++ b/iterator/iter_fwd.h @@ -89,7 +89,7 @@ struct iter_forward_zone { * Create forwards * @return new forwards or NULL on error. */ -struct iter_forwards* forwards_create(); +struct iter_forwards* forwards_create(void); /** * Delete forwards. diff --git a/iterator/iter_hints.c b/iterator/iter_hints.c index 7ded69823..d896d680f 100644 --- a/iterator/iter_hints.c +++ b/iterator/iter_hints.c @@ -51,7 +51,7 @@ #include "util/data/dname.h" struct iter_hints* -hints_create() +hints_create(void) { struct iter_hints* hints = (struct iter_hints*)calloc(1, sizeof(struct iter_hints)); diff --git a/iterator/iter_hints.h b/iterator/iter_hints.h index 8a3974489..4540971b0 100644 --- a/iterator/iter_hints.h +++ b/iterator/iter_hints.h @@ -81,7 +81,7 @@ struct iter_hints_stub { * Create hints * @return new hints or NULL on error. */ -struct iter_hints* hints_create(); +struct iter_hints* hints_create(void); /** * Delete hints. diff --git a/iterator/iter_priv.c b/iterator/iter_priv.c index 2d97a93ad..fcfe5d677 100644 --- a/iterator/iter_priv.c +++ b/iterator/iter_priv.c @@ -51,7 +51,7 @@ #include "util/net_help.h" #include "util/storage/dnstree.h" -struct iter_priv* priv_create() +struct iter_priv* priv_create(void) { struct iter_priv* priv = (struct iter_priv*)calloc(1, sizeof(*priv)); if(!priv) diff --git a/iterator/iter_priv.h b/iterator/iter_priv.h index 164f69cc7..8140559f7 100644 --- a/iterator/iter_priv.h +++ b/iterator/iter_priv.h @@ -74,7 +74,7 @@ struct iter_priv { * Create priv structure * @return new structure or NULL on error. */ -struct iter_priv* priv_create(); +struct iter_priv* priv_create(void); /** * Delete priv structure. diff --git a/iterator/iter_resptype.c b/iterator/iter_resptype.c index 5d4844720..a41ee55ae 100644 --- a/iterator/iter_resptype.c +++ b/iterator/iter_resptype.c @@ -141,7 +141,7 @@ response_type_from_server(int rdset, * answer is there directly, our answer is there after * a cname, or there is just a cname. */ for(i=0; irep->an_numrrsets; i++) { - struct ub_packed_rrset_key* s = msg->rep->rrsets[i]; + s = msg->rep->rrsets[i]; /* if the answer section has NS rrset, and qtype ANY * and the delegation is lower, and no CNAMEs followed, diff --git a/iterator/iterator.c b/iterator/iterator.c index 8f662fbec..f716be15a 100644 --- a/iterator/iterator.c +++ b/iterator/iterator.c @@ -463,8 +463,7 @@ handle_cname_response(struct module_qstate* qstate, struct iter_qstate* iq, * @param initial_state The initial response state (normally this * is QUERY_RESP_STATE, unless it is known that the request won't * need iterative processing - * @param final_state The final state for the response to this - * request. + * @param finalstate The final state for the response to this request. * @param subq_ret: if newly allocated, the subquerystate, or NULL if it does * not need initialisation. * @param v: if true, validation is done on the subquery. @@ -474,13 +473,13 @@ static int generate_sub_request(uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct module_qstate* qstate, int id, struct iter_qstate* iq, enum iter_state initial_state, - enum iter_state final_state, struct module_qstate** subq_ret, int v) + enum iter_state finalstate, struct module_qstate** subq_ret, int v) { struct module_qstate* subq = NULL; struct iter_qstate* subiq = NULL; uint16_t qflags = 0; /* OPCODE QUERY, no flags */ struct query_info qinf; - int prime = (final_state == PRIME_RESP_STATE)?1:0; + int prime = (finalstate == PRIME_RESP_STATE)?1:0; qinf.qname = qname; qinf.qname_len = qnamelen; qinf.qtype = qtype; @@ -523,7 +522,7 @@ generate_sub_request(uint8_t* qname, size_t qnamelen, uint16_t qtype, subiq->depth = iq->depth+1; outbound_list_init(&subiq->outlist); subiq->state = initial_state; - subiq->final_state = final_state; + subiq->final_state = finalstate; subiq->qchase = subq->qinfo; subiq->chase_flags = subq->query_flags; subiq->refetch_glue = 0; @@ -2672,7 +2671,7 @@ static struct module_func_block iter_block = { }; struct module_func_block* -iter_get_funcblock() +iter_get_funcblock(void) { return &iter_block; } diff --git a/iterator/iterator.h b/iterator/iterator.h index 59dd4b16b..a2d3eab47 100644 --- a/iterator/iterator.h +++ b/iterator/iterator.h @@ -314,7 +314,7 @@ struct iter_prep_list { * Get the iterator function block. * @return: function block with function pointers to iterator methods. */ -struct module_func_block* iter_get_funcblock(); +struct module_func_block* iter_get_funcblock(void); /** * Get iterator state as a string diff --git a/libunbound/libunbound.c b/libunbound/libunbound.c index 804eb9675..e75eb1c7e 100644 --- a/libunbound/libunbound.c +++ b/libunbound/libunbound.c @@ -67,7 +67,7 @@ #endif /* UB_ON_WINDOWS */ struct ub_ctx* -ub_ctx_create() +ub_ctx_create(void) { struct ub_ctx* ctx; unsigned int seed; diff --git a/pythonmod/pythonmod.c b/pythonmod/pythonmod.c index 1753869e5..d253cd274 100644 --- a/pythonmod/pythonmod.c +++ b/pythonmod/pythonmod.c @@ -375,7 +375,7 @@ static struct module_func_block pythonmod_block = { &pythonmod_clear, &pythonmod_get_mem }; -struct module_func_block* pythonmod_get_funcblock() +struct module_func_block* pythonmod_get_funcblock(void) { return &pythonmod_block; } diff --git a/pythonmod/pythonmod.h b/pythonmod/pythonmod.h index fef806713..b108cf923 100644 --- a/pythonmod/pythonmod.h +++ b/pythonmod/pythonmod.h @@ -46,7 +46,7 @@ * Get the module function block. * @return: function block with function pointers to module methods. */ -struct module_func_block* pythonmod_get_funcblock(); +struct module_func_block* pythonmod_get_funcblock(void); /** python module init */ int pythonmod_init(struct module_env* env, int id); diff --git a/services/localzone.c b/services/localzone.c index 248d45f9b..452d043e9 100644 --- a/services/localzone.c +++ b/services/localzone.c @@ -52,7 +52,7 @@ #include "util/data/msgparse.h" struct local_zones* -local_zones_create() +local_zones_create(void) { struct local_zones* zones = (struct local_zones*)calloc(1, sizeof(*zones)); @@ -290,7 +290,7 @@ get_rr_nameclass(const char* str, uint8_t** nm, uint16_t* dclass) * @param type: type to look for (host order). * @return rrset pointer or NULL if not found. */ -struct local_rrset* +static struct local_rrset* local_data_find_type(struct local_data* data, uint16_t type) { struct local_rrset* p; diff --git a/services/localzone.h b/services/localzone.h index ed05a5831..38f4524e5 100644 --- a/services/localzone.h +++ b/services/localzone.h @@ -149,7 +149,7 @@ struct local_rrset { * Create local zones storage * @return new struct or NULL on error. */ -struct local_zones* local_zones_create(); +struct local_zones* local_zones_create(void); /** * Delete local zones storage diff --git a/testcode/asynclook.c b/testcode/asynclook.c index 6abab7b22..7ec013c0c 100644 --- a/testcode/asynclook.c +++ b/testcode/asynclook.c @@ -84,7 +84,7 @@ struct lookinfo { static int num_wait = 0; /** usage information for asynclook */ -void usage(char* argv[]) +static void usage(char* argv[]) { printf("usage: %s [options] name ...\n", argv[0]); printf("names are looked up at the same time, asynchronously.\n"); diff --git a/testcode/checklocks.c b/testcode/checklocks.c index 520e6ddd1..68cd419df 100644 --- a/testcode/checklocks.c +++ b/testcode/checklocks.c @@ -68,7 +68,7 @@ int check_locking_order = 1; static pid_t check_lock_pid; /** print all possible debug info on the state of the system */ -static void total_debug_info(); +static void total_debug_info(void); /** print pretty lock error and exit */ static void lock_error(struct checked_lock* lock, @@ -674,7 +674,7 @@ static void* checklock_main(void* arg) } /** init the main thread */ -void checklock_start() +void checklock_start(void) { if(!key_created) { struct thr_check* thisthr = (struct thr_check*)calloc(1, @@ -692,7 +692,7 @@ void checklock_start() } /** stop checklocks */ -void checklock_stop() +void checklock_stop(void) { if(key_created) { int i; @@ -726,7 +726,7 @@ checklock_thrcreate(pthread_t* id, void* (*func)(void*), void* arg) /** count number of thread infos */ static int -count_thread_infos() +count_thread_infos(void) { int cnt = 0; int i; @@ -795,7 +795,7 @@ thread_debug_info(struct thr_check* thr) } static void -total_debug_info() +total_debug_info(void) { int i; log_info("checklocks: supervising %d threads.", diff --git a/testcode/checklocks.h b/testcode/checklocks.h index cf62cb58d..de901da9a 100644 --- a/testcode/checklocks.h +++ b/testcode/checklocks.h @@ -206,12 +206,12 @@ size_t lock_get_mem(void* lock); /** * Initialise checklock. Sets up internal debug structures. */ -void checklock_start(); +void checklock_start(void); /** * Cleanup internal debug state. */ -void checklock_stop(); +void checklock_stop(void); /** * Init locks. diff --git a/testcode/delayer.c b/testcode/delayer.c index b3b6ffcdb..b42a3b1aa 100644 --- a/testcode/delayer.c +++ b/testcode/delayer.c @@ -139,7 +139,7 @@ struct tcp_proxy { }; /** usage information for delayer */ -void usage(char* argv[]) +static void usage(char* argv[]) { printf("usage: %s [options]\n", argv[0]); printf(" -f addr : use addr, forward to that server, @port.\n"); diff --git a/testcode/fake_event.c b/testcode/fake_event.c index 1fd80d2b1..15c1ef527 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -98,7 +98,7 @@ fake_event_init(struct replay_scenario* scen) } void -fake_event_cleanup() +fake_event_cleanup(void) { replay_scenario_delete(saved_scenario); saved_scenario = NULL; diff --git a/testcode/fake_event.h b/testcode/fake_event.h index 236be03b6..1a73de824 100644 --- a/testcode/fake_event.h +++ b/testcode/fake_event.h @@ -61,7 +61,7 @@ void fake_event_init(struct replay_scenario* scen); /** * Deinit fake event services. */ -void fake_event_cleanup(); +void fake_event_cleanup(void); /** * Get filename to store temporary config stuff. The pid is added. in /tmp. diff --git a/testcode/perf.c b/testcode/perf.c index e079a19ea..8dd697d52 100644 --- a/testcode/perf.c +++ b/testcode/perf.c @@ -492,13 +492,13 @@ qlist_parse_line(ldns_buffer* buf, char* p) ldns_buffer_write_u16_at(buf, 0, 0); /* zero ID */ if(rec) LDNS_RD_SET(ldns_buffer_begin(buf)); if(edns) { - struct edns_data edns; - memset(&edns, 0, sizeof(edns)); - edns.edns_present = 1; - edns.udp_size = EDNS_ADVERTISED_SIZE; + struct edns_data ed; + memset(&ed, 0, sizeof(ed)); + ed.edns_present = 1; + ed.udp_size = EDNS_ADVERTISED_SIZE; /* Set DO bit in all EDNS datagrams ... */ - edns.bits = EDNS_DO; - attach_edns_record(buf, &edns); + ed.bits = EDNS_DO; + attach_edns_record(buf, &ed); } ldns_rdf_deep_free(rdf); return 1; diff --git a/testcode/pktview.c b/testcode/pktview.c index 494f8e7b3..fe202e71d 100644 --- a/testcode/pktview.c +++ b/testcode/pktview.c @@ -48,7 +48,7 @@ #include "testcode/readhex.h" /** usage information for pktview */ -void usage(char* argv[]) +static void usage(char* argv[]) { printf("usage: %s\n", argv[0]); printf("present hex packet on stdin.\n"); @@ -56,7 +56,7 @@ void usage(char* argv[]) } /** read hex input */ -void read_input(ldns_buffer* pkt, FILE* in) +static void read_input(ldns_buffer* pkt, FILE* in) { char buf[102400]; char* np = buf; @@ -69,7 +69,7 @@ void read_input(ldns_buffer* pkt, FILE* in) } /** analyze domain name in packet, possibly compressed */ -void analyze_dname(ldns_buffer* pkt) +static void analyze_dname(ldns_buffer* pkt) { size_t oldpos = ldns_buffer_position(pkt); size_t len; @@ -84,7 +84,7 @@ void analyze_dname(ldns_buffer* pkt) } /** analyze rdata in packet */ -void analyze_rdata(ldns_buffer*pkt, const ldns_rr_descriptor* desc, +static void analyze_rdata(ldns_buffer*pkt, const ldns_rr_descriptor* desc, uint16_t rdlen) { int rdf = 0; @@ -124,7 +124,7 @@ void analyze_rdata(ldns_buffer*pkt, const ldns_rr_descriptor* desc, } /** analyze rr in packet */ -void analyze_rr(ldns_buffer* pkt, int q) +static void analyze_rr(ldns_buffer* pkt, int q) { uint16_t type, dclass, len; uint32_t ttl; @@ -150,7 +150,7 @@ void analyze_rr(ldns_buffer* pkt, int q) } /** analyse pkt */ -void analyze(ldns_buffer* pkt) +static void analyze(ldns_buffer* pkt) { uint16_t i, f, qd, an, ns, ar; int rrnum = 0; diff --git a/testcode/replay.c b/testcode/replay.c index 375fe2653..c8b23fee1 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -624,7 +624,7 @@ do_macro_recursion(rbtree_t* store, struct replay_runtime* runtime, } /** get var from store */ -struct replay_var* +static struct replay_var* macro_getvar(rbtree_t* store, char* name) { struct replay_var k; diff --git a/testcode/streamtcp.c b/testcode/streamtcp.c index 7dbac38fa..39d2db317 100644 --- a/testcode/streamtcp.c +++ b/testcode/streamtcp.c @@ -58,7 +58,7 @@ #endif /** usage information for streamtcp */ -void usage(char* argv[]) +static void usage(char* argv[]) { printf("usage: %s [options] name type class ...\n", argv[0]); printf(" sends the name-type-class queries over TCP.\n"); diff --git a/testcode/testbound.c b/testcode/testbound.c index b283c11d9..c28b8bca7 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -82,14 +82,14 @@ testbound_usage() /** * Add options from string to passed argc. splits on whitespace. - * @param optarg: the option argument, "-v -p 12345" or so. + * @param args: the option argument, "-v -p 12345" or so. * @param pass_argc: ptr to the argc for unbound. Modified. * @param pass_argv: the argv to pass to unbound. Modified. */ static void -add_opts(const char* optarg, int* pass_argc, char* pass_argv[]) +add_opts(const char* args, int* pass_argc, char* pass_argv[]) { - const char *p = optarg, *np; + const char *p = args, *np; size_t len; while(p && isspace((int)*p)) p++; diff --git a/testcode/unitanchor.c b/testcode/unitanchor.c index 346b417b7..e79eef098 100644 --- a/testcode/unitanchor.c +++ b/testcode/unitanchor.c @@ -121,7 +121,7 @@ test_anchors(ldns_buffer* buff, struct val_anchors* a) unit_assert(anchors_lookup(a, (uint8_t*)"\002oo\000", 4, c) == NULL); } -void anchors_test() +void anchors_test(void) { ldns_buffer* buff = ldns_buffer_new(65800); struct val_anchors* a; diff --git a/testcode/unitdname.c b/testcode/unitdname.c index fda2fd4e0..6a078a6a3 100644 --- a/testcode/unitdname.c +++ b/testcode/unitdname.c @@ -100,7 +100,7 @@ dname_test_qdtl(ldns_buffer* buff) /** test query_dname_compare */ static void -dname_test_query_dname_compare() +dname_test_query_dname_compare(void) { unit_show_func("util/data/dname.c", "query_dname_compare"); unit_assert(query_dname_compare((uint8_t*)"", (uint8_t*)"") == 0); @@ -130,7 +130,7 @@ dname_test_query_dname_compare() /** test dname_count_labels */ static void -dname_test_count_labels() +dname_test_count_labels(void) { unit_show_func("util/data/dname.c", "dname_count_labels"); unit_assert(dname_count_labels((uint8_t*)"") == 1); @@ -143,7 +143,7 @@ dname_test_count_labels() /** test dname_count_size_labels */ static void -dname_test_count_size_labels() +dname_test_count_size_labels(void) { size_t sz = 0; unit_show_func("util/data/dname.c", "dname_count_size_labels"); @@ -270,7 +270,7 @@ dname_test_pkt_dname_len(ldns_buffer* buff) /** test dname_lab_cmp */ static void -dname_test_dname_lab_cmp() +dname_test_dname_lab_cmp(void) { int ml = 0; /* number of labels that matched exactly */ unit_show_func("util/data/dname.c", "dname_lab_cmp"); @@ -372,7 +372,7 @@ dname_test_dname_lab_cmp() /** test dname_subdomain_c */ static void -dname_test_subdomain() +dname_test_subdomain(void) { unit_show_func("util/data/dname.c", "dname_subdomain"); unit_assert(dname_subdomain_c( @@ -409,7 +409,7 @@ dname_test_subdomain() /** test dname_strict_subdomain */ static void -dname_test_strict_subdomain() +dname_test_strict_subdomain(void) { unit_show_func("util/data/dname.c", "dname_strict_subdomain"); unit_assert(!dname_strict_subdomain( @@ -446,7 +446,7 @@ dname_test_strict_subdomain() /** test dname_is_root */ static void -dname_test_isroot() +dname_test_isroot(void) { unit_show_func("util/data/dname.c", "dname_isroot"); unit_assert(dname_is_root((uint8_t*)"\000")); @@ -459,7 +459,7 @@ dname_test_isroot() /** test dname_remove_label */ static void -dname_test_removelabel() +dname_test_removelabel(void) { uint8_t* orig = (uint8_t*)"\007example\003com\000"; uint8_t* n = orig; @@ -478,7 +478,7 @@ dname_test_removelabel() /** test dname_signame_label_count */ static void -dname_test_sigcount() +dname_test_sigcount(void) { unit_show_func("util/data/dname.c", "dname_signame_label_count"); unit_assert(dname_signame_label_count((uint8_t*)"\000") == 0); @@ -498,7 +498,7 @@ dname_test_sigcount() /** test dname_is_wild routine */ static void -dname_test_iswild() +dname_test_iswild(void) { unit_show_func("util/data/dname.c", "dname_iswild"); unit_assert( !dname_is_wild((uint8_t*)"\000") ); @@ -509,7 +509,7 @@ dname_test_iswild() /** test dname_canonical_compare */ static void -dname_test_canoncmp() +dname_test_canoncmp(void) { unit_show_func("util/data/dname.c", "dname_canonical_compare"); /* equality */ @@ -729,7 +729,7 @@ dname_test_canoncmp() /** Test dname_get_shared_topdomain */ static void -dname_test_topdomain() +dname_test_topdomain(void) { unit_show_func("util/data/dname.c", "dname_get_shared_topdomain"); unit_assert( query_dname_compare( @@ -751,7 +751,7 @@ dname_test_topdomain() /** Test dname_valid */ static void -dname_test_valid() +dname_test_valid(void) { unit_show_func("util/data/dname.c", "dname_valid"); unit_assert( dname_valid( @@ -831,7 +831,7 @@ dname_setup_bufs(ldns_buffer* loopbuf, ldns_buffer* boundbuf) ldns_buffer_flip(boundbuf); } -void dname_test() +void dname_test(void) { ldns_buffer* loopbuf = ldns_buffer_new(14); ldns_buffer* boundbuf = ldns_buffer_new(16); diff --git a/testcode/unitlruhash.c b/testcode/unitlruhash.c index 048ed5531..3bb7c2626 100644 --- a/testcode/unitlruhash.c +++ b/testcode/unitlruhash.c @@ -477,7 +477,7 @@ test_threaded_table(struct lruhash* table) if(0) lruhash_status(table, "hashtest", 1); } -void lruhash_test() +void lruhash_test(void) { /* start very very small array, so it can do lots of table_grow() */ /* also small in size so that reclaim has to be done quickly. */ diff --git a/testcode/unitmain.c b/testcode/unitmain.c index 6258316c9..c0985106c 100644 --- a/testcode/unitmain.c +++ b/testcode/unitmain.c @@ -65,7 +65,7 @@ int testcount = 0; #include "util/alloc.h" /** test alloc code */ static void -alloc_test() { +alloc_test(void) { alloc_special_t *t1, *t2; struct alloc_cache major, minor1, minor2; int i; @@ -104,7 +104,7 @@ alloc_test() { #include "util/net_help.h" /** test net code */ static void -net_test() +net_test(void) { const char* t4[] = {"\000\000\000\000", "\200\000\000\000", @@ -309,7 +309,7 @@ net_test() #include "util/config_file.h" /** test config_file: cfg_parse_memsize */ static void -config_memsize_test() +config_memsize_test(void) { size_t v = 0; unit_show_func("util/config_file.c", "cfg_parse_memsize"); @@ -348,7 +348,7 @@ config_memsize_test() #include "util/rtt.h" /** test RTT code */ static void -rtt_test() +rtt_test(void) { int init = 376; int i; @@ -375,7 +375,7 @@ rtt_test() #include "util/config_file.h" /** test host cache */ static void -infra_test() +infra_test(void) { struct sockaddr_storage one; socklen_t onelen; @@ -444,7 +444,7 @@ infra_test() #include "util/random.h" /** test randomness */ static void -rnd_test() +rnd_test(void) { struct ub_randstate* r; int num = 1000, i; diff --git a/testcode/unitmain.h b/testcode/unitmain.h index fb4319b18..6cfad3eb5 100644 --- a/testcode/unitmain.h +++ b/testcode/unitmain.h @@ -57,20 +57,20 @@ void unit_show_func(const char* file, const char* func); void unit_show_feature(const char* feature); /** unit test lruhashtable implementation */ -void lruhash_test(); +void lruhash_test(void); /** unit test slabhashtable implementation */ -void slabhash_test(); +void slabhash_test(void); /** unit test for msgreply and msgparse */ -void msgparse_test(); +void msgparse_test(void); /** unit test dname handling functions */ -void dname_test(); +void dname_test(void); /** unit test trust anchor storage functions */ -void anchors_test(); +void anchors_test(void); /** unit test for verification functions */ -void verify_test(); +void verify_test(void); /** unit test for negative cache functions */ -void neg_test(); +void neg_test(void); /** unit test for regional allocator functions */ -void regional_test(); +void regional_test(void); #endif /* TESTCODE_UNITMAIN_H */ diff --git a/testcode/unitmsgparse.c b/testcode/unitmsgparse.c index d1ef854bd..1d4d1a3f2 100644 --- a/testcode/unitmsgparse.c +++ b/testcode/unitmsgparse.c @@ -573,7 +573,7 @@ testfromdrillfile(ldns_buffer* pkt, struct alloc_cache* alloc, fclose(in); } -void msgparse_test() +void msgparse_test(void) { ldns_buffer* pkt = ldns_buffer_new(65553); ldns_buffer* out = ldns_buffer_new(65553); diff --git a/testcode/unitneg.c b/testcode/unitneg.c index f71d0d346..e18aefc34 100644 --- a/testcode/unitneg.c +++ b/testcode/unitneg.c @@ -91,7 +91,7 @@ static void print_neg_cache(struct val_neg_cache* neg) } /** get static pointer to random zone name */ -static char* get_random_zone() +static char* get_random_zone(void) { static char zname[256]; int labels = random() % 3; @@ -526,7 +526,7 @@ static void stress_test(struct val_neg_cache* neg) } } -void neg_test() +void neg_test(void) { struct val_neg_cache* neg; srandom(48); diff --git a/testcode/unitregional.c b/testcode/unitregional.c index 3d9223f3a..93249deb4 100644 --- a/testcode/unitregional.c +++ b/testcode/unitregional.c @@ -195,7 +195,7 @@ corner_cases(struct regional* r) /** test specific cases */ static void -specific_cases() +specific_cases(void) { struct regional* r = regional_create(); corner_cases(r); @@ -228,7 +228,7 @@ burden_test(size_t max) /** randomly allocate stuff */ static void -random_burden() +random_burden(void) { size_t max_alloc = 2048 + 128; /* small chance of LARGE */ int i; @@ -236,7 +236,7 @@ random_burden() burden_test(max_alloc); } -void regional_test() +void regional_test(void) { unit_show_feature("regional"); specific_cases(); diff --git a/testcode/unitslabhash.c b/testcode/unitslabhash.c index 149cccc8b..70f1c58b0 100644 --- a/testcode/unitslabhash.c +++ b/testcode/unitslabhash.c @@ -356,7 +356,7 @@ test_threaded_table(struct slabhash* table) if(0) slabhash_status(table, "hashtest", 1); } -void slabhash_test() +void slabhash_test(void) { /* start very very small array, so it can do lots of table_grow() */ /* also small in size so that reclaim has to be done quickly. */ diff --git a/testcode/unitverify.c b/testcode/unitverify.c index ec8f2b10a..4679cef8d 100644 --- a/testcode/unitverify.c +++ b/testcode/unitverify.c @@ -343,7 +343,7 @@ unitest_nsec_has_type_rdata(char* bitmap, size_t len, uint16_t type) /** Test NSEC type bitmap routine */ static void -nsectest() +nsectest(void) { /* bitmap starts at type bitmap rdata field */ /* from rfc 4034 example */ @@ -465,7 +465,7 @@ nsec3_hash_test(const char* fname) } void -verify_test() +verify_test(void) { unit_show_feature("signature verify"); verifytest_file("testdata/test_signatures.1", "20070818005004"); diff --git a/util/config_file.c b/util/config_file.c index ec0866c25..a406ac970 100644 --- a/util/config_file.c +++ b/util/config_file.c @@ -70,7 +70,7 @@ int ub_c_wrap(void); static void init_outgoing_availports(int* array, int num); struct config_file* -config_create() +config_create(void) { struct config_file* cfg; cfg = (struct config_file*)calloc(1, sizeof(struct config_file)); @@ -198,7 +198,7 @@ error_exit: return NULL; } -struct config_file* config_create_forlib() +struct config_file* config_create_forlib(void) { struct config_file* cfg = config_create(); if(!cfg) return NULL; @@ -848,7 +848,7 @@ int cfg_condense_ports(struct config_file* cfg, int** avail) } /** print error with file and line number */ -void ub_c_error_va_list(const char *fmt, va_list args) +static void ub_c_error_va_list(const char *fmt, va_list args) { cfg_parser->errors++; fprintf(stderr, "%s:%d: error: ", cfg_parser->filename, @@ -873,7 +873,7 @@ void ub_c_error(const char *str) cfg_parser->line, str); } -int ub_c_wrap() +int ub_c_wrap(void) { return 1; } diff --git a/util/config_file.h b/util/config_file.h index 0ad374f44..85e781c63 100644 --- a/util/config_file.h +++ b/util/config_file.h @@ -327,13 +327,13 @@ struct config_strlist_head { * Create config file structure. Filled with default values. * @return: the new structure or NULL on memory error. */ -struct config_file* config_create(); +struct config_file* config_create(void); /** * Create config file structure for library use. Filled with default values. * @return: the new structure or NULL on memory error. */ -struct config_file* config_create_forlib(); +struct config_file* config_create_forlib(void); /** * Read the config file from the specified filename. diff --git a/util/locks.c b/util/locks.c index 272eb7a8e..425f9b9d4 100644 --- a/util/locks.c +++ b/util/locks.c @@ -48,7 +48,7 @@ /** block all signals, masks them away. */ void -ub_thread_blocksigs() +ub_thread_blocksigs(void) { #if defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS) || defined(HAVE_SIGPROCMASK) # if defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS) diff --git a/util/locks.h b/util/locks.h index 911b7ce1d..91be5c3e2 100644 --- a/util/locks.h +++ b/util/locks.h @@ -63,10 +63,10 @@ * The errno is logged to the logfile with a descriptive comment. */ #define LOCKRET(func) do {\ - int err; \ - if( (err=(func)) != 0) \ + int lockret_err; \ + if( (lockret_err=(func)) != 0) \ log_err("%s at %d could not " #func ": %s", \ - __FILE__, __LINE__, strerror(err)); \ + __FILE__, __LINE__, strerror(lockret_err)); \ } while(0) /** DEBUG: use thread debug whenever possible */ @@ -283,7 +283,7 @@ typedef void* ub_thread_key_t; * Block all signals for this thread. * fatal exit on error. */ -void ub_thread_blocksigs(); +void ub_thread_blocksigs(void); /** * unblock one signal for this thread. diff --git a/util/netevent.c b/util/netevent.c index a04a7cfcc..8b479bfb1 100644 --- a/util/netevent.c +++ b/util/netevent.c @@ -333,7 +333,7 @@ comm_point_send_udp_msg(struct comm_point *c, ldns_buffer* packet, } /** print debug ancillary info */ -void p_ancil(const char* str, struct comm_reply* r) +static void p_ancil(const char* str, struct comm_reply* r) { #if defined(AF_INET6) && defined(IPV6_PKTINFO) && (defined(HAVE_RECVMSG) || defined(HAVE_SENDMSG)) if(r->srctype != 4 && r->srctype != 6) { @@ -380,7 +380,7 @@ void p_ancil(const char* str, struct comm_reply* r) } /** send a UDP reply over specified interface*/ -int +static int comm_point_send_udp_msg_if(struct comm_point *c, ldns_buffer* packet, struct sockaddr* addr, socklen_t addrlen, struct comm_reply* r) { @@ -482,7 +482,7 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg) struct comm_reply rep; struct msghdr msg; struct iovec iov[1]; - ssize_t recv; + ssize_t rcv; char ancil[256]; int i; #ifndef S_SPLINT_S @@ -512,15 +512,15 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg) msg.msg_controllen = sizeof(ancil); #endif /* S_SPLINT_S */ msg.msg_flags = 0; - recv = recvmsg(fd, &msg, 0); - if(recv == -1) { + rcv = recvmsg(fd, &msg, 0); + if(rcv == -1) { if(errno != EAGAIN && errno != EINTR) { log_err("recvmsg failed: %s", strerror(errno)); } return; } rep.addrlen = msg.msg_namelen; - ldns_buffer_skip(rep.c->buffer, recv); + ldns_buffer_skip(rep.c->buffer, rcv); ldns_buffer_flip(rep.c->buffer); rep.srctype = 0; #ifndef S_SPLINT_S @@ -574,7 +574,7 @@ void comm_point_udp_callback(int fd, short event, void* arg) { struct comm_reply rep; - ssize_t recv; + ssize_t rcv; int i; rep.c = (struct comm_point*)arg; @@ -589,10 +589,10 @@ comm_point_udp_callback(int fd, short event, void* arg) rep.addrlen = (socklen_t)sizeof(rep.addr); log_assert(fd != -1); log_assert(ldns_buffer_remaining(rep.c->buffer) > 0); - recv = recvfrom(fd, (void*)ldns_buffer_begin(rep.c->buffer), + rcv = recvfrom(fd, (void*)ldns_buffer_begin(rep.c->buffer), ldns_buffer_remaining(rep.c->buffer), 0, (struct sockaddr*)&rep.addr, &rep.addrlen); - if(recv == -1) { + if(rcv == -1) { #ifndef USE_WINSOCK if(errno != EAGAIN && errno != EINTR) log_err("recvfrom %d failed: %s", @@ -606,7 +606,7 @@ comm_point_udp_callback(int fd, short event, void* arg) #endif return; } - ldns_buffer_skip(rep.c->buffer, recv); + ldns_buffer_skip(rep.c->buffer, rcv); ldns_buffer_flip(rep.c->buffer); rep.srctype = 0; fptr_ok(fptr_whitelist_comm_point(rep.c->callback)); diff --git a/util/regional.c b/util/regional.c index 37f243909..8b1fcdbb2 100644 --- a/util/regional.c +++ b/util/regional.c @@ -63,7 +63,7 @@ #endif struct regional* -regional_create() +regional_create(void) { return regional_create_custom(REGIONAL_CHUNK_SIZE); } diff --git a/util/regional.h b/util/regional.h index 6090b8804..250523a6d 100644 --- a/util/regional.h +++ b/util/regional.h @@ -80,7 +80,7 @@ struct regional * Create a new regional. * @return: newly allocated regional. */ -struct regional* regional_create(); +struct regional* regional_create(void); /** * Create a new region, with custom settings. diff --git a/util/timehist.c b/util/timehist.c index 02d5df059..38e642778 100644 --- a/util/timehist.c +++ b/util/timehist.c @@ -80,7 +80,7 @@ dosetup(struct timehist* hist) } } -struct timehist* timehist_setup() +struct timehist* timehist_setup(void) { struct timehist* hist = (struct timehist*)calloc(1, sizeof(struct timehist)); @@ -184,7 +184,7 @@ void timehist_log(struct timehist* hist, const char* name) } /** total number in histogram */ -size_t +static size_t timehist_count(struct timehist* hist) { size_t i, res = 0; diff --git a/util/timehist.h b/util/timehist.h index ab23f0128..d59448399 100644 --- a/util/timehist.h +++ b/util/timehist.h @@ -71,7 +71,7 @@ struct timehist { * Setup a histogram, default * @return histogram or NULL on malloc failure. */ -struct timehist* timehist_setup(); +struct timehist* timehist_setup(void); /** * Delete histogram diff --git a/validator/autotrust.c b/validator/autotrust.c index b1170ed7f..f31f62792 100644 --- a/validator/autotrust.c +++ b/validator/autotrust.c @@ -2001,19 +2001,19 @@ autr_debug_print_tp(struct trust_anchor* tp) log_info("assembled %d DS and %d DNSKEYs", (int)tp->numDS, (int)tp->numDNSKEY); if(0) { /* turned off because it prints to stderr */ - ldns_buffer* buf = ldns_buffer_new(70000); + ldns_buffer* bf = ldns_buffer_new(70000); ldns_rr_list* list; if(tp->ds_rrset) { - list = packed_rrset_to_rr_list(tp->ds_rrset, buf); + list = packed_rrset_to_rr_list(tp->ds_rrset, bf); ldns_rr_list_print(stderr, list); ldns_rr_list_deep_free(list); } if(tp->dnskey_rrset) { - list = packed_rrset_to_rr_list(tp->dnskey_rrset, buf); + list = packed_rrset_to_rr_list(tp->dnskey_rrset, bf); ldns_rr_list_print(stderr, list); ldns_rr_list_deep_free(list); } - ldns_buffer_free(buf); + ldns_buffer_free(bf); } log_info("file %s", tp->autr->file); ctime_r(&tp->autr->last_queried, buf); diff --git a/validator/val_anchor.c b/validator/val_anchor.c index 0b4ca4259..97bec6a5f 100644 --- a/validator/val_anchor.c +++ b/validator/val_anchor.c @@ -72,7 +72,7 @@ anchor_cmp(const void* k1, const void* k2) } struct val_anchors* -anchors_create() +anchors_create(void) { struct val_anchors* a = (struct val_anchors*)calloc(1, sizeof(*a)); if(!a) diff --git a/validator/val_anchor.h b/validator/val_anchor.h index 5a5fa4855..d2f3afc43 100644 --- a/validator/val_anchor.h +++ b/validator/val_anchor.h @@ -132,7 +132,7 @@ struct trust_anchor { * Create trust anchor storage * @return new storage or NULL on error. */ -struct val_anchors* anchors_create(); +struct val_anchors* anchors_create(void); /** * Delete trust anchor storage. diff --git a/validator/validator.c b/validator/validator.c index f46656df6..a8cb07279 100644 --- a/validator/validator.c +++ b/validator/validator.c @@ -2918,7 +2918,7 @@ static struct module_func_block val_block = { }; struct module_func_block* -val_get_funcblock() +val_get_funcblock(void) { return &val_block; } diff --git a/validator/validator.h b/validator/validator.h index bad084790..18e905efc 100644 --- a/validator/validator.h +++ b/validator/validator.h @@ -250,7 +250,7 @@ struct val_qstate { * Get the validator function block. * @return: function block with function pointers to validator methods. */ -struct module_func_block* val_get_funcblock(); +struct module_func_block* val_get_funcblock(void); /** * Get validator state as a string