diff --git a/bin/tests/adb_test.c b/bin/tests/adb_test.c index f5e1469b7d..e3086e59f8 100644 --- a/bin/tests/adb_test.c +++ b/bin/tests/adb_test.c @@ -59,7 +59,7 @@ isc_stdtime_t now; dns_adb_t *adb; static void -check_result(isc_result_t result, char *format, ...) { +check_result(isc_result_t result, const char *format, ...) { va_list args; if (result == ISC_R_SUCCESS) @@ -217,7 +217,7 @@ create_view(void) { } static void -lookup(char *target) { +lookup(const char *target) { dns_name_t name; unsigned char namedata[256]; client_t *client; diff --git a/bin/tests/compress_test.c b/bin/tests/compress_test.c index 821f29086c..5a06d01283 100644 --- a/bin/tests/compress_test.c +++ b/bin/tests/compress_test.c @@ -125,7 +125,7 @@ test(unsigned int allowed, dns_name_t *name1, dns_name_t *name2, unsigned char buf2[1024]; if (verbose) { - char *s; + const char *s; switch (allowed) { case DNS_COMPRESS_NONE: s = "DNS_COMPRESS_NONE"; break; case DNS_COMPRESS_GLOBAL14: s = "DNS_COMPRESS_GLOBAL14"; break; diff --git a/bin/tests/db/t_db.c b/bin/tests/db/t_db.c index 5f1cc991dc..97fa931c75 100644 --- a/bin/tests/db/t_db.c +++ b/bin/tests/db/t_db.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -35,13 +36,13 @@ #include static isc_result_t -t_create(char *db_type, char *origin, char *class, char *cache, - isc_mem_t *mctx, dns_db_t **db) +t_create(const char *db_type, const char *origin, const char *class, + const char *cache, isc_mem_t *mctx, dns_db_t **db) { int len; isc_result_t dns_result; isc_boolean_t iscache; - isc_textregion_t textregion; + isc_constregion_t region; isc_buffer_t origin_buffer; dns_fixedname_t dns_origin; dns_rdataclass_t rdataclass; @@ -63,9 +64,10 @@ t_create(char *db_type, char *origin, char *class, char *cache, return(dns_result); } - textregion.base = class; - textregion.length = strlen(class); - dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); + region.base = class; + region.length = strlen(class); + dns_result = dns_rdataclass_fromtext(&rdataclass, + (isc_textregion_t *)®ion); if (dns_result != ISC_R_SUCCESS) { t_info("dns_rdataclass_fromtext failed %s\n", dns_result_totext(dns_result)); @@ -218,7 +220,7 @@ t_dns_db_load(char **av) { return(result); } -static char *a1 = +static const char *a1 = "A call to dns_db_load(db, filename) loads the contents of " "the database in filename into db."; @@ -232,7 +234,7 @@ t1(void) { } -static char *a2 = +static const char *a2 = "When the database db has cache semantics, a call to " "dns_db_iscache(db) returns ISC_TRUE."; @@ -315,7 +317,7 @@ t_dns_db_zc_x(char *filename, char *db_type, char *origin, char *class, } static int -test_dns_db_zc_x(char *filename, isc_boolean_t cache, +test_dns_db_zc_x(const char *filename, isc_boolean_t cache, isc_boolean_t(*cf)(dns_db_t *), isc_boolean_t exp_result) { @@ -394,7 +396,7 @@ t2(void) { } -static char *a3 = +static const char *a3 = "When the database db has zone semantics, a call to " "dns_db_iscache(db) returns ISC_FALSE."; @@ -410,7 +412,7 @@ t3(void) { } -static char *a4 = +static const char *a4 = "When the database db has zone semantics, a call to " "dns_db_iszone(db) returns ISC_TRUE."; @@ -426,7 +428,7 @@ t4(void) { } -static char *a5 = +static const char *a5 = "When the database db has cache semantics, a call to " "dns_db_iszone(db) returns ISC_FALSE."; @@ -521,7 +523,7 @@ t_dns_db_origin(char **av) { } -static char *a6 = +static const char *a6 = "A call to dns_db_origin(db) returns the origin of the database."; static void @@ -534,7 +536,7 @@ t6(void) { } -static char *a7 = +static const char *a7 = "A call to dns_db_class(db) returns the class of the database."; @@ -625,7 +627,7 @@ t7(void) { } -static char *a8 = +static const char *a8 = "A call to dns_db_currentversion() opens the current " "version for reading."; @@ -859,7 +861,7 @@ t8(void) { t_result(result); } -static char *a9 = +static const char *a9 = "A call to dns_db_newversion() opens a new version for " "reading and writing."; @@ -888,6 +890,7 @@ t_dns_db_newversion(char **av) { dns_fixedname_t dns_newname; dns_fixedname_t dns_foundname; dns_rdata_t added_rdata; + const char * added_rdata_data; dns_rdataset_t added_rdataset; dns_rdata_t found_rdata; dns_rdataset_t found_rdataset; @@ -998,7 +1001,8 @@ t_dns_db_newversion(char **av) { } dns_rdata_init(&added_rdata); - added_rdata.data = (unsigned char *)"\x10\x00\x00\x01"; + added_rdata_data = "\x10\x00\x00\x01"; + DE_CONST(added_rdata_data, added_rdata.data); added_rdata.length = 4; added_rdata.rdclass = rdataclass; added_rdata.type = rdatatype; @@ -1131,7 +1135,7 @@ t9(void) { t_result(result); } -static char *a10 = +static const char *a10 = "When versionp points to a read-write version and commit is " "ISC_TRUE, a call to dns_db_closeversion(db, versionp, commit) " "causes all changes made in the version to take effect, " @@ -1164,6 +1168,7 @@ t_dns_db_closeversion_1(char **av) { dns_fixedname_t dns_foundname; dns_fixedname_t dns_existingname; dns_rdata_t added_rdata; + const char * added_rdata_data; dns_rdataset_t added_rdataset; dns_rdata_t found_rdata; dns_rdataset_t found_rdataset; @@ -1348,7 +1353,8 @@ t_dns_db_closeversion_1(char **av) { } dns_rdata_init(&added_rdata); - added_rdata.data = (unsigned char *)"\x10\x00\x00\x01"; + added_rdata_data = "\x10\x00\x00\x01"; + DE_CONST(added_rdata_data, added_rdata.data); added_rdata.length = 4; added_rdata.rdclass = rdataclass; added_rdata.type = new_rdatatype; @@ -1490,7 +1496,7 @@ t10(void) { t_result(result); } -static char *a11 = +static const char *a11 = "When versionp points to a read-write version and commit is " "ISC_FALSE, a call to dns_db_closeversion(db, versionp, commit) " "causes all changes made in the version to to be rolled back, " @@ -1523,6 +1529,7 @@ t_dns_db_closeversion_2(char **av) { dns_fixedname_t dns_foundname; dns_fixedname_t dns_existingname; dns_rdata_t added_rdata; + const char * added_rdata_data; dns_rdataset_t added_rdataset; dns_rdata_t found_rdata; dns_rdataset_t found_rdataset; @@ -1661,7 +1668,7 @@ t_dns_db_closeversion_2(char **av) { &name_buffer, NULL, ISC_FALSE, NULL); if (dns_result != ISC_R_SUCCESS) { t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_detach(&db); isc_mem_destroy(&mctx); @@ -1672,7 +1679,7 @@ t_dns_db_closeversion_2(char **av) { ISC_TRUE, &nodep); if (dns_result != ISC_R_SUCCESS) { t_info("dns_db_findnode failed %s\n", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_detach(&db); isc_mem_destroy(&mctx); @@ -1684,8 +1691,7 @@ t_dns_db_closeversion_2(char **av) { dns_result = dns_rdatatype_fromtext(&new_rdatatype, &textregion); if (dns_result != ISC_R_SUCCESS) { t_info("dns_rdatatype_fromtext %s failed %s\n", - new_type, - dns_result_totext(dns_result)); + new_type, dns_result_totext(dns_result)); dns_db_detachnode(db, &nodep); dns_db_detach(&db); isc_mem_destroy(&mctx); @@ -1697,7 +1703,7 @@ t_dns_db_closeversion_2(char **av) { dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); if (dns_result != ISC_R_SUCCESS) { t_info("dns_rdataclass_fromtext failed %s\n", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); dns_db_detachnode(db, &nodep); dns_db_detach(&db); isc_mem_destroy(&mctx); @@ -1705,7 +1711,8 @@ t_dns_db_closeversion_2(char **av) { } dns_rdata_init(&added_rdata); - added_rdata.data = (unsigned char *)"\x10\x00\x00\x01"; + added_rdata_data = "\x10\x00\x00\x01"; + DE_CONST(added_rdata_data, added_rdata.data); added_rdata.length = 4; added_rdata.rdclass = rdataclass; added_rdata.type = new_rdatatype; @@ -1721,7 +1728,7 @@ t_dns_db_closeversion_2(char **av) { dns_result = dns_rdatalist_tordataset(&rdatalist, &added_rdataset); if (dns_result != ISC_R_SUCCESS) { t_info("dns_rdatalist_tordataset failed %s\n", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); dns_db_detachnode(db, &nodep); dns_db_detach(&db); isc_mem_destroy(&mctx); @@ -1732,7 +1739,7 @@ t_dns_db_closeversion_2(char **av) { &added_rdataset, 0, NULL); if (dns_result != ISC_R_SUCCESS) { t_info("dns_db_addrdataset failed %s\n", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_detachnode(db, &nodep); dns_db_detach(&db); @@ -1761,7 +1768,7 @@ t_dns_db_closeversion_2(char **av) { (dns_result == DNS_R_NXRRSET)) { t_info("dns_db_find failed %s\n", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_detachnode(db, &nodep); if (dns_rdataset_isassociated(&found_rdataset)) @@ -1911,7 +1918,7 @@ t11(void) { t_result(result); } -static char *a12 = +static const char *a12 = "A call to dns_db_expirenode() marks as stale all records at node " "which expire at or before 'now'. If 'now' is zero, then the current " "time will be used."; @@ -2086,7 +2093,7 @@ t12(void) { t_result(result); } -static char *a13 = +static const char *a13 = "If the node name exists, then a call to " "dns_db_findnode(db, name, ISC_FALSE, nodep) initializes nodep " "to point to the node and returns ISC_R_SUCCESS, otherwise " @@ -2232,7 +2239,7 @@ t13(void) { t_result(result); } -static char *a14 = +static const char *a14 = "If the node name does not exist and create is ISC_TRUE, " "then a call to dns_db_findnode(db, name, create, nodep) " "creates the node, initializes nodep to point to the node, " @@ -2560,7 +2567,7 @@ t_dns_db_find_x(char **av) { return(result); } -static char *a15 = +static const char *a15 = "A call to dns_db_find(db, name, version, type, options, now, ...) " "finds the best match for 'name' and 'type' in version 'version' " "of 'db'."; @@ -2575,7 +2582,7 @@ t15(void) { } -static char *a16 = +static const char *a16 = "When the desired node and type were found, but are glue, " "and the DNS_DBFIND_GLUEOK option is set, a call to " "dns_db_find(db, name, version, type, options, now, ...) " @@ -2590,7 +2597,7 @@ t16(void) { t_result(result); } -static char *a17 = +static const char *a17 = "A call to dns_db_find() returns DNS_R_DELEGATION when the data " "requested is beneath a zone cut."; @@ -2603,7 +2610,7 @@ t17(void) { t_result(result); } -static char *a18 = +static const char *a18 = "A call to dns_db_find() returns DNS_R_ZONECUT when type is " "dns_rdatatype_any and the desired node is a zone cut."; @@ -2616,7 +2623,7 @@ t18(void) { t_result(result); } -static char *a19 = +static const char *a19 = "A call to dns_db_find() returns DNS_R_DNAME when the data " "requested is beneath a DNAME."; @@ -2629,7 +2636,7 @@ t19(void) { t_result(result); } -static char *a20 = +static const char *a20 = "A call to dns_db_find() returns DNS_R_CNAME when the requested " "rdataset was not found but there is a CNAME at the desired name."; @@ -2642,7 +2649,7 @@ t20(void) { t_result(result); } -static char *a21 = +static const char *a21 = "A call to dns_db_find() returns DNS_R_NXDOMAIN when name " "does not exist."; @@ -2655,7 +2662,7 @@ t21(void) { t_result(result); } -static char *a22 = +static const char *a22 = "A call to dns_db_find() returns DNS_R_NXRRSET when " "the desired name exists, but the desired type does not."; @@ -2668,7 +2675,7 @@ t22(void) { t_result(result); } -static char *a23 = +static const char *a23 = "When db is a cache database, a call to dns_db_find() " "returns ISC_R_NOTFOUND when the desired name does not exist, " "and no delegation could be found."; @@ -2682,7 +2689,7 @@ t23(void) { t_result(result); } -static char *a24 = +static const char *a24 = "When db is a cache database, an rdataset will be found only " "if at least one rdataset at the found node expires after 'now'."; diff --git a/bin/tests/db_test.c b/bin/tests/db_test.c index 21a9a6c3a8..a61b6d98c0 100644 --- a/bin/tests/db_test.c +++ b/bin/tests/db_test.c @@ -64,7 +64,7 @@ static int pause_every = 0; static isc_boolean_t ascending = ISC_TRUE; static void -print_result(char *message, isc_result_t result) { +print_result(const char *message, isc_result_t result) { size_t len; if (message == NULL) { @@ -235,7 +235,7 @@ list(dbinfo *dbi, char *seektext) { } static isc_result_t -load(char *filename, char *origintext, isc_boolean_t cache) { +load(const char *filename, const char *origintext, isc_boolean_t cache) { dns_fixedname_t forigin; dns_name_t *origin; isc_result_t result; diff --git a/bin/tests/dispatch_tcp_test.c b/bin/tests/dispatch_tcp_test.c index 37838c8550..236221c29e 100644 --- a/bin/tests/dispatch_tcp_test.c +++ b/bin/tests/dispatch_tcp_test.c @@ -46,13 +46,8 @@ unsigned char render_buffer[1024]; dns_rdataset_t rdataset; dns_rdatalist_t rdatalist; -void my_accept(isc_task_t *, isc_event_t *); -void got_request(isc_task_t *, isc_event_t *); -void got_response(isc_task_t *, isc_event_t *); -void start_response(void); -static inline void CHECKRESULT(isc_result_t, char *); -void send_done(isc_task_t *, isc_event_t *); -void hex_dump(isc_buffer_t *); +static void +got_request(isc_task_t *, isc_event_t *); static isc_result_t printmsg(dns_message_t *msg, FILE *out) { @@ -68,12 +63,12 @@ printmsg(dns_message_t *msg, FILE *out) { fprintf(out, "msg:\n%*s\n", isc_buffer_usedlength(&textbuf), - isc_buffer_base(&textbuf)); + (char *)isc_buffer_base(&textbuf)); return (ISC_R_SUCCESS); } -void +static void hex_dump(isc_buffer_t *b) { unsigned int len; isc_region_t r; @@ -91,7 +86,7 @@ hex_dump(isc_buffer_t *b) { } static inline void -CHECKRESULT(isc_result_t result, char *msg) { +CHECKRESULT(isc_result_t result, const char *msg) { if (result != ISC_R_SUCCESS) { printf("%s: %s\n", msg, isc_result_totext(result)); @@ -99,7 +94,7 @@ CHECKRESULT(isc_result_t result, char *msg) { } } -void +static void my_accept(isc_task_t *task, isc_event_t *ev_in) { isc_socket_newconnev_t *ev = (isc_socket_newconnev_t *)ev_in; dns_dispentry_t *resp; @@ -132,160 +127,7 @@ my_accept(isc_task_t *task, isc_event_t *ev_in) { isc_event_free(&ev_in); } -void -send_done(isc_task_t *task, isc_event_t *ev_in) { - isc_socketevent_t *ev = (isc_socketevent_t *)ev_in; - dns_dispentry_t *resp = (dns_dispentry_t *)ev_in->ev_arg; - - (void)task; - - if (ev->result == ISC_R_SUCCESS) { - printf("Send done (SUCCESS)\n"); - isc_event_free(&ev_in); - return; - } - - CHECKRESULT(ev->result, "send_done got event"); - - isc_event_free(&ev_in); - - printf("--- removing response (FAILURE)\n"); - dns_dispatch_removeresponse(&resp, NULL); - isc_app_shutdown(); -} - -void -start_response(void) { - dns_dispentry_t *resp; - dns_messageid_t id; - isc_sockaddr_t from; - dns_message_t *msg; - isc_result_t result; - dns_name_t *name; - unsigned char namebuf[255]; - isc_buffer_t target; - isc_buffer_t source; - isc_region_t region; - -#define QUESTION "flame.org." - - isc_buffer_init(&source, QUESTION, strlen(QUESTION)); - isc_buffer_add(&source, strlen(QUESTION)); - isc_buffer_setactive(&source, strlen(QUESTION)); - isc_buffer_init(&target, namebuf, sizeof(namebuf)); - - memset(&from, 0, sizeof(from)); - from.length = sizeof(struct sockaddr_in); -#ifdef ISC_PLATFORM_HAVESALEN - from.type.sa.sa_len = sizeof(struct sockaddr_in); -#endif - from.type.sin.sin_port = htons(53); - from.type.sa.sa_family = AF_INET; - RUNTIME_CHECK(inet_aton("204.152.184.97", - &from.type.sin.sin_addr) == 1); - - msg = NULL; - result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &msg); - CHECKRESULT(result, "dns_message_create()"); - - name = NULL; - result = dns_message_gettempname(msg, &name); - CHECKRESULT(result, "dns_message_gettempname()"); - - dns_name_init(name, NULL); - result = dns_name_fromtext(name, &source, dns_rootname, ISC_FALSE, - &target); - CHECKRESULT(result, "dns_name_fromtext()"); - - dns_message_addname(msg, name, DNS_SECTION_QUESTION); - - rdatalist.rdclass = dns_rdataclass_in; - rdatalist.type = dns_rdatatype_a; - rdatalist.ttl = 0; - ISC_LIST_INIT(rdatalist.rdata); - - dns_rdataset_init(&rdataset); - result = dns_rdatalist_tordataset(&rdatalist, &rdataset); - CHECKRESULT(result, "dns_rdatalist_tordataset()"); - - ISC_LIST_APPEND(name->list, &rdataset, link); - - result = printmsg(msg, stderr); - CHECKRESULT(result, "printmsg()"); - - isc_buffer_init(&render, render_buffer, sizeof(render_buffer)); - result = dns_message_renderbegin(msg, &render); - CHECKRESULT(result, "dns_message_renderbegin()"); - - rdataset.attributes |= DNS_RDATASETATTR_QUESTION; - - result = dns_message_rendersection(msg, DNS_SECTION_QUESTION, 0); - CHECKRESULT(result, "dns_message_rendersection(QUESTION)"); - - result = dns_message_rendersection(msg, DNS_SECTION_ANSWER, 0); - CHECKRESULT(result, "dns_message_rendersection(ANSWER)"); - - result = dns_message_rendersection(msg, DNS_SECTION_ADDITIONAL, 0); - CHECKRESULT(result, "dns_message_rendersection(ADDITIONAL)"); - - result = dns_message_rendersection(msg, DNS_SECTION_AUTHORITY, 0); - CHECKRESULT(result, "dns_message_rendersection(AUTHORITY)"); - - printf("--- adding response\n"); - resp = NULL; - result = dns_dispatch_addresponse(disp, &from, t0, got_response, NULL, - &id, &resp); - CHECKRESULT(result, "dns_dispatch_addresponse"); - - printf("Assigned MessageID %d\n", id); - - msg->opcode = dns_opcode_query; - msg->rcode = dns_rcode_noerror; - msg->flags = DNS_MESSAGEFLAG_RD; - msg->id = id; - - result = dns_message_renderend(msg); - CHECKRESULT(result, "dns_message_renderend"); - - dns_message_destroy(&msg); - - isc_buffer_usedregion(&render, ®ion); - result = isc_socket_send(dns_dispatch_getsocket(disp), ®ion, - t0, send_done, resp); - CHECKRESULT(result, "isc_socket_send()"); -} - -void -got_response(isc_task_t *task, isc_event_t *ev_in) { - dns_dispatchevent_t *ev = (dns_dispatchevent_t *)ev_in; - dns_dispentry_t *resp = ev->ev_sender; - dns_message_t *msg; - isc_result_t result; - - (void)task; - - printf("App: Got response (id %d). Result: %s\n", - ev->id, isc_result_totext(ev->result)); - - msg = NULL; - result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg); - CHECKRESULT(result, "dns_message_create() failed"); - - result = dns_message_parse(msg, &ev->buffer, ISC_FALSE); - CHECKRESULT(result, "dns_message_parse() failed"); - - result = printmsg(msg, stderr); - CHECKRESULT(result, "printmsg() failed"); - - dns_message_destroy(&msg); - - printf("--- removing response\n"); - dns_dispatch_removeresponse(&resp, &ev); - - isc_app_shutdown(); -} - -void +static void got_request(isc_task_t *task, isc_event_t *ev_in) { dns_dispatchevent_t *ev = (dns_dispatchevent_t *)ev_in; dns_dispentry_t *resp = ev->ev_sender; diff --git a/bin/tests/dispatch_test.c b/bin/tests/dispatch_test.c index b3765274a5..70385f6f76 100644 --- a/bin/tests/dispatch_test.c +++ b/bin/tests/dispatch_test.c @@ -75,7 +75,7 @@ printmsg(dns_message_t *msg, FILE *out) { fprintf(out, "msg:\n%*s\n", isc_buffer_usedlength(&textbuf), - isc_buffer_base(&textbuf)); + (char *)isc_buffer_base(&textbuf)); return (ISC_R_SUCCESS); } @@ -98,7 +98,7 @@ hex_dump(isc_buffer_t *b) { } static inline void -CHECKRESULT(isc_result_t result, char *msg) { +CHECKRESULT(isc_result_t result, const char *msg) { if (result != ISC_R_SUCCESS) { printf("%s: %s\n", msg, isc_result_totext(result)); @@ -129,7 +129,7 @@ send_done(isc_task_t *task, isc_event_t *ev_in) { } static void -start_response(clictx_t *cli, char *query, isc_task_t *task) { +start_response(clictx_t *cli, const char *query, isc_task_t *task) { dns_messageid_t id; isc_sockaddr_t from; dns_message_t *msg; diff --git a/bin/tests/dst/dst_test.c b/bin/tests/dst/dst_test.c index 5b9f0fb82f..b9bc7ac148 100644 --- a/bin/tests/dst/dst_test.c +++ b/bin/tests/dst/dst_test.c @@ -33,18 +33,21 @@ #include #include -char *current, *tmp = "/tmp"; +char *current; +const char *tmp = "/tmp"; static void use(dst_key_t *key) { isc_result_t ret; - char *data = "This is some data"; + const char *data = "This is some data"; unsigned char sig[512]; isc_buffer_t databuf, sigbuf; isc_region_t datareg, sigreg; isc_buffer_init(&sigbuf, sig, sizeof(sig)); - /* Advance 1 byte for fun */ + /* + * Advance 1 byte for fun. + */ isc_buffer_add(&sigbuf, 1); isc_buffer_init(&databuf, data, strlen(data)); diff --git a/bin/tests/dst/t_dst.c b/bin/tests/dst/t_dst.c index 2b44c1906d..9bf8783ba6 100644 --- a/bin/tests/dst/t_dst.c +++ b/bin/tests/dst/t_dst.c @@ -81,7 +81,7 @@ static void use(dst_key_t *key, isc_result_t exp_result, int *nfails) { isc_result_t ret; - char *data = "This is some data"; + const char *data = "This is some data"; unsigned char sig[512]; isc_buffer_t databuf, sigbuf; isc_region_t datareg, sigreg; @@ -359,7 +359,7 @@ get_random(int *nfails) { } } -static char *a1 = +static const char *a1 = "the dst module provides the capability to " "generate, store and retrieve public and private keys, " "sign and verify data using the RSA, DSA and MD5 algorithms, " @@ -753,7 +753,7 @@ t2_sigchk(char *datapath, char *sigpath, char *keyname, * signed at some earlier time, possibly with an entire different * version or implementation of the DSA and RSA algorithms */ -static char *a2 = +static const char *a2 = "the dst module provides the capability to " "verify data signed with the RSA and DSA algorithms"; diff --git a/bin/tests/log_test.c b/bin/tests/log_test.c index cc35e4c937..fc74f4d4c5 100644 --- a/bin/tests/log_test.c +++ b/bin/tests/log_test.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: log_test.c,v 1.16 2000/05/16 03:33:51 tale Exp $ */ +/* $Id: log_test.c,v 1.17 2000/06/01 19:10:41 tale Exp $ */ /* Principal Authors: DCL */ @@ -44,7 +44,7 @@ char usage[] = "Usage: %s [-m] [-s syslog_logfile] [-r file_versions]\n"; int main (int argc, char **argv) { - char *progname, *syslog_file, *message; + const char *progname, *syslog_file, *message; int ch, i, file_versions, stderr_line; isc_boolean_t show_final_mem = ISC_FALSE; isc_log_t *lctx; @@ -52,8 +52,8 @@ main (int argc, char **argv) { isc_mem_t *mctx; isc_result_t result; isc_logdestination_t destination; - isc_logcategory_t *category; - isc_logmodule_t *module; + const isc_logcategory_t *category; + const isc_logmodule_t *module; progname = strrchr(*argv, '/'); if (progname != NULL) @@ -116,7 +116,7 @@ main (int argc, char **argv) { CHECK(isc_mem_create(0, 0, &mctx)); CHECK(isc_log_create(mctx, &lctx, &lcfg)); - isc_log_settag(lcfg, progname); + CHECK(isc_log_settag(lcfg, progname)); isc_log_setcontext(lctx); dns_log_init(lctx); diff --git a/bin/tests/lwres_test.c b/bin/tests/lwres_test.c index 6f1d76b0b9..222a48ebc3 100644 --- a/bin/tests/lwres_test.c +++ b/bin/tests/lwres_test.c @@ -29,7 +29,7 @@ #define USE_ISC_MEM static inline void -CHECK(int val, char *msg) { +CHECK(int val, const char *msg) { if (val != 0) { fprintf(stderr, "%s returned %d\n", msg, val); exit(1); @@ -37,7 +37,7 @@ CHECK(int val, char *msg) { } static void -hexdump(char *msg, void *base, size_t len) { +hexdump(const char *msg, void *base, size_t len) { unsigned char *p; unsigned int cnt; @@ -62,7 +62,7 @@ hexdump(char *msg, void *base, size_t len) { printf("\n"); } -static char *TESTSTRING = "This is a test. This is only a test. !!!"; +static const char *TESTSTRING = "This is a test. This is only a test. !!!"; static lwres_context_t *ctx; static void @@ -79,7 +79,8 @@ test_noop(void) { pkt.result = 0; nooprequest.datalength = strlen(TESTSTRING); - nooprequest.data = (unsigned char *) TESTSTRING; + /* XXXDCL maybe "nooprequest.data" should be const. */ + DE_CONST(TESTSTRING, nooprequest.data); ret = lwres_nooprequest_render(ctx, &nooprequest, &pkt, &b); CHECK(ret, "lwres_nooprequest_render"); @@ -114,7 +115,8 @@ test_noop(void) { pkt.result = 0xdeadbeef; noopresponse.datalength = strlen(TESTSTRING); - noopresponse.data = (unsigned char *) TESTSTRING; + /* XXXDCL maybe "noopresponse.data" should be const. */ + DE_CONST(TESTSTRING, noopresponse.data); ret = lwres_noopresponse_render(ctx, &noopresponse, &pkt, &b); CHECK(ret, "lwres_noopresponse_render"); @@ -145,7 +147,7 @@ test_noop(void) { } static void -test_gabn(char *target) { +test_gabn(const char *target) { lwres_gabnresponse_t *res; lwres_addr_t *addr; int ret; @@ -189,7 +191,7 @@ test_gabn(char *target) { } static void -test_gnba(char *target, lwres_uint32_t af) { +test_gnba(const char *target, lwres_uint32_t af) { lwres_gnbaresponse_t *res; int ret; unsigned int i; diff --git a/bin/tests/lwresconf_test.c b/bin/tests/lwresconf_test.c index 241c25c3ff..f39356411c 100644 --- a/bin/tests/lwresconf_test.c +++ b/bin/tests/lwresconf_test.c @@ -27,7 +27,7 @@ #define USE_ISC_MEM static inline void -CHECK(int val, char *msg) { +CHECK(int val, const char *msg) { if (val != 0) { fprintf(stderr, "%s returned %d\n", msg, val); exit(1); diff --git a/bin/tests/master/t_master.c b/bin/tests/master/t_master.c index 341ae54381..f4dc478485 100644 --- a/bin/tests/master/t_master.c +++ b/bin/tests/master/t_master.c @@ -136,8 +136,7 @@ test_master(char *testfile, char *origin, char *class, isc_result_t exp_result) } static int -test_master_x(char *filename) { - +test_master_x(const char *filename) { FILE *fp; char *p; int line; @@ -181,7 +180,7 @@ test_master_x(char *filename) { return(result); } -static char *a1 = "dns_master_loadfile loads a valid master file and " +static const char *a1 = "dns_master_loadfile loads a valid master file and " "returns ISC_R_SUCCESS"; static void t1(void) { @@ -191,8 +190,9 @@ t1(void) { t_result(result); } -static char *a2 = "dns_master_loadfile returns ISC_R_UNEXPECTEDEND when the " - "masterfile input ends unexpectedly"; +static const char *a2 = + "dns_master_loadfile returns ISC_R_UNEXPECTEDEND when the " + "masterfile input ends unexpectedly"; static void t2(void) { @@ -202,7 +202,7 @@ t2(void) { t_result(result); } -static char *a3 = "dns_master_loadfile returns DNS_R_NOOWNER when the " +static const char *a3 = "dns_master_loadfile returns DNS_R_NOOWNER when the " "an ownername is not specified"; static void @@ -213,7 +213,7 @@ t3() { t_result(result); } -static char *a4 = "dns_master_loadfile returns DNS_R_NOTTL when the " +static const char *a4 = "dns_master_loadfile returns DNS_R_NOTTL when the " "the ttl is not specified"; static void @@ -224,7 +224,7 @@ t4() { t_result(result); } -static char *a5 = "dns_master_loadfile returns DNS_R_BADCLASS when the " +static const char *a5 = "dns_master_loadfile returns DNS_R_BADCLASS when the " "the record class did not match the zone class"; static void @@ -237,8 +237,9 @@ t5() { t_result(result); } -static char *a6 = "dns_master_loadfile understands KEY RR specifications " - "containing key material"; +static const char *a6 = + "dns_master_loadfile understands KEY RR specifications " + "containing key material"; static void t6() { @@ -250,8 +251,9 @@ t6() { t_result(result); } -static char *a7 = "dns_master_loadfile understands KEY RR specifications " - "containing no key material"; +static const char *a7 = + "dns_master_loadfile understands KEY RR specifications " + "containing no key material"; static void t7() { diff --git a/bin/tests/mem/t_mem.c b/bin/tests/mem/t_mem.c index 9414766b3a..31f3b9a40e 100644 --- a/bin/tests/mem/t_mem.c +++ b/bin/tests/mem/t_mem.c @@ -180,7 +180,7 @@ memtest(void) { return(0); } -static char *a1 = +static const char *a1 = "the memory module supports the creation of memory contexts " "and the management of memory pools."; static void diff --git a/bin/tests/names/t_names.c b/bin/tests/names/t_names.c index 3471ef9a83..aba2225bce 100644 --- a/bin/tests/names/t_names.c +++ b/bin/tests/names/t_names.c @@ -34,8 +34,9 @@ #define BUFLEN 256 #define BIGBUFLEN 4096 -char *a1 = "dns_label_countbits returns the number of " - "bits in a bitstring label"; +static const char *a1 = + "dns_label_countbits returns the number of " + "bits in a bitstring label"; static char *Tokens[MAXTOKS + 1]; @@ -429,8 +430,8 @@ t_dns_label_countbits(void) { } } -char *a2 = "dns_label_getbit returns the n'th most significant " - "bit of a bitstring label"; +static const char *a2 = "dns_label_getbit returns the n'th most significant " + "bit of a bitstring label"; static int test_dns_label_getbit(char *test_name, int label_pos, int bit_pos, @@ -514,7 +515,7 @@ t_dns_label_getbit(void) { } } -char *a3 = "dns_name_init initializes 'name' to the empty name"; +static const char *a3 = "dns_name_init initializes 'name' to the empty name"; static void t_dns_name_init(void) { @@ -565,7 +566,7 @@ t_dns_name_init(void) { t_result(result); } -char *a4 = "dns_name_invalidate invalidates 'name'"; +static const char *a4 = "dns_name_invalidate invalidates 'name'"; static void t_dns_name_invalidate(void) { @@ -618,8 +619,8 @@ t_dns_name_invalidate(void) { t_result(result); } -char *a5 = "dns_name_setbuffer dedicates a binary buffer for use " - "with 'name'"; +static const char *a5 = "dns_name_setbuffer dedicates a binary buffer for use " + "with 'name'"; static void t_dns_name_setbuffer(void) { @@ -641,8 +642,8 @@ t_dns_name_setbuffer(void) { t_result(result); } -char *a6 = "dns_name_hasbuffer returns ISC_TRUE if 'name' has a " - "dedicated buffer, otherwise it returns ISC_FALSE"; +static const char *a6 = "dns_name_hasbuffer returns ISC_TRUE if 'name' has a " + "dedicated buffer, otherwise it returns ISC_FALSE"; static void t_dns_name_hasbuffer(void) { @@ -670,8 +671,8 @@ t_dns_name_hasbuffer(void) { t_result(result); } -char *a7 = "dns_name_isabsolute returns ISC_TRUE if 'name' ends " - "in the root label"; +static const char *a7 = "dns_name_isabsolute returns ISC_TRUE if 'name' ends " + "in the root label"; static int test_dns_name_isabsolute(char *test_name, isc_boolean_t expected) { @@ -756,7 +757,7 @@ t_dns_name_isabsolute(void) { } } -char *a8 = "dns_name_hash(name, case_sensitive) returns " +static const char *a8 = "dns_name_hash(name, case_sensitive) returns " "a hash of 'name' which is case_sensitive if case_sensitive " "is true"; @@ -871,7 +872,8 @@ t_dns_name_hash(void) { } } -char *a10 = "dns_name_fullcompare(name1, name2, orderp, nlabelsp, nbitsp) " +static const char *a10 = + "dns_name_fullcompare(name1, name2, orderp, nlabelsp, nbitsp) " "returns the DNSSEC ordering relationship between name1 and " "name2, sets orderp to -1 if name1 < name2, to 0 if " "name1 == name2, or to 1 if name1 > name2, sets nlabelsp " @@ -882,9 +884,9 @@ char *a10 = "dns_name_fullcompare(name1, name2, orderp, nlabelsp, nbitsp) " /* * a11 thru a22 merged into a10. */ -static char * +static const char * dns_namereln_to_text(dns_namereln_t reln) { - char *p; + const char *p; if (reln == dns_namereln_contains) p = "contains"; @@ -1044,7 +1046,8 @@ t_dns_name_fullcompare(void) { } } -char *a23 = "dns_name_compare(name1, name2) returns information about " +static const char *a23 = + "dns_name_compare(name1, name2) returns information about " "the relative ordering under the DNSSEC ordering relationship " "of name1 and name2"; @@ -1144,7 +1147,8 @@ t_dns_name_compare(void) { } } -char *a30 = "dns_name_rdatacompare(name1, name2) returns information " +static const char *a30 = + "dns_name_rdatacompare(name1, name2) returns information " "about the relative ordering of name1 and name2 as if they " "are part of rdata in DNSSEC canonical form"; @@ -1244,7 +1248,8 @@ t_dns_name_rdatacompare(void) { } -char *a33 = "when name1 is a subdomain of name2, " +static const char *a33 = + "when name1 is a subdomain of name2, " "dns_name_issubdomain(name1, name2) returns true, " "otherwise it returns false."; @@ -1339,7 +1344,8 @@ t_dns_name_issubdomain(void) { } } -char *a35 = "dns_name_countlabels(name) returns the number " +static const char *a35 = + "dns_name_countlabels(name) returns the number " "of labels in name"; static int @@ -1415,7 +1421,8 @@ t_dns_name_countlabels(void) { } } -char *a36 = "when n is less than the number of labels in name, " +static const char *a36 = + "when n is less than the number of labels in name, " "dns_name_getlabel(name, n, labelp) initializes labelp " "to point to the nth label in name"; @@ -1526,7 +1533,8 @@ t_dns_name_getlabel(void) { } } -char *a37 = "when source contains at least first + n labels, " +static const char *a37 = + "when source contains at least first + n labels, " "dns_name_getlabelsequence(source, first, n, target) " "initializes target to point to the n label sequence of " "labels in source starting with first"; @@ -1655,7 +1663,8 @@ t_dns_name_getlabelsequence(void) { } } -char *a38 = "dns_name_fromregion(name, region) converts a DNS name " +static const char *a38 = + "dns_name_fromregion(name, region) converts a DNS name " "from a region representation to a name representation"; static int @@ -1738,7 +1747,8 @@ t_dns_name_fromregion(void) { } } -char *a39 = "dns_name_toregion(name, region) converts a DNS name " +static const char *a39 = + "dns_name_toregion(name, region) converts a DNS name " "from a region representation to a name representation"; static void @@ -1785,7 +1795,8 @@ t_dns_name_toregion(void) { } } -char *a40 = "dns_name_fromtext(name, source, origin, downcase, target) " +static const char *a40 = + "dns_name_fromtext(name, source, origin, downcase, target) " "converts the textual representation of a DNS name at source " "into uncompressed wire form at target, appending origin to " "the converted name if origin is non-NULL and converting " @@ -1927,7 +1938,8 @@ t_dns_name_fromtext(void) { } } -char *a41 = "dns_name_totext(name, omit_final_dot, target) converts " +static const char *a41 = + "dns_name_totext(name, omit_final_dot, target) converts " "the DNS name 'name' in wire format to textual format " "at target, and adds a final '.' to the name if " "omit_final_dot is false"; @@ -2057,41 +2069,56 @@ t_dns_name_totext(void) { } } -char *a42 = "dns_name_fromwire(name, source, dctx, downcase, target) " +static const char *a42 = + "dns_name_fromwire(name, source, dctx, downcase, target) " "converts the possibly compressed DNS name 'name' in wire " "format to canonicalized form at target, performing upper to " "lower case conversion if downcase is true, and returns " "ISC_R_SUCCESS"; -char *a43 = "when a label length is invalid, dns_name_fromwire() " +#if 0 + /* + * XXXRTH these tests appear to be broken, so I have + * disabled them. + */ +static const char *a43 = + "when a label length is invalid, dns_name_fromwire() " "returns ISC_R_NOSPACE"; -char *a44 = "when a label type is invalid, dns_name_fromwire() " +static const char *a44 = + "when a label type is invalid, dns_name_fromwire() " "returns DNS_R_BADLABELTYPE"; +#endif -char *a45 = "when a name length is invalid, dns_name_fromwire() " +static const char *a45 = + "when a name length is invalid, dns_name_fromwire() " "returns ISC_R_NOSPACE"; -char *a46 = "when a compression type is invalid, dns_name_fromwire() " +static const char *a46 = + "when a compression type is invalid, dns_name_fromwire() " "returns DNS_R_DISALLOWED"; -char *a47 = "when a bad compression pointer is encountered, " +static const char *a47 = + "when a bad compression pointer is encountered, " "dns_name_fromwire() returns DNS_R_BADPOINTER"; -char *a48 = "when input ends unexpected, dns_name_fromwire() " +static const char *a48 = + "when input ends unexpected, dns_name_fromwire() " "returns ISC_R_UNEXPECTEDEND"; -char *a49 = "when there are too many compression pointers, " +static const char *a49 = + "when there are too many compression pointers, " "dns_name_fromwire() returns DNS_R_TOOMANYHOPS"; -char *a50 = "when there is not enough space in target, " +static const char *a50 = + "when there is not enough space in target, " "dns_name_fromwire(name, source, dcts, downcase, target) " "returns ISC_R_NOSPACE"; static int test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase, - int dc_method, char *exp_name, isc_result_t exp_result, - size_t buflen) + unsigned int dc_method, char *exp_name, + isc_result_t exp_result, size_t buflen) { int result; int order; @@ -2156,11 +2183,11 @@ test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase, } static void -t_dns_name_fromwire_x(char *testfile, size_t buflen) { +t_dns_name_fromwire_x(const char *testfile, size_t buflen) { int line; int cnt; int result; - int dc_method; + unsigned int dc_method; isc_result_t exp_result; char *p; char *tok; @@ -2242,11 +2269,11 @@ t_dns_name_fromwire(void) { t_assert("dns_name_fromwire", 1, T_REQUIRED, a42); t_dns_name_fromwire_x("dns_name_fromwire_1_data", BUFLEN); +#if 0 /* * XXXRTH these tests appear to be broken, so I have * disabled them. */ -#if 0 t_assert("dns_name_fromwire", 2, T_REQUIRED, a43); t_dns_name_fromwire_x("dns_name_fromwire_2_data", BUFLEN); @@ -2274,16 +2301,18 @@ t_dns_name_fromwire(void) { } -char *a51 = "dns_name_towire(name, cctx, target) converts the DNS name " +static const char *a51 = + "dns_name_towire(name, cctx, target) converts the DNS name " "'name' into wire format, compresses it as specified " "by the compression context cctx, stores the result in " "target and returns DNS_SUCCESS"; -char *a52 = "when not enough space exists in target, " +static const char *a52 = + "when not enough space exists in target, " "dns_name_towire(name, cctx, target) returns ISC_R_NOSPACE"; static int -test_dns_name_towire(char *testname, int dc_method, char *exp_data, +test_dns_name_towire(char *testname, unsigned int dc_method, char *exp_data, int exp_data_len, isc_result_t exp_result, size_t buflen) { int result; @@ -2348,11 +2377,11 @@ test_dns_name_towire(char *testname, int dc_method, char *exp_data, } static void -t_dns_name_towire_x(char *testfile, size_t buflen) { +t_dns_name_towire_x(const char *testfile, size_t buflen) { int line; int cnt; int result; - int dc_method; + unsigned int dc_method; isc_result_t exp_result; char *p; FILE *fp; @@ -2420,7 +2449,8 @@ t_dns_name_towire(void) { t_dns_name_towire_2(); } -char *a53 = "dns_name_concatenate(prefix, suffix, name, target) " +static const char *a53 = + "dns_name_concatenate(prefix, suffix, name, target) " "concatenates prefix and suffix, stores the result " "in target, canonicalizes any bitstring labels " "and returns ISC_R_SUCCESS"; diff --git a/bin/tests/nxtify.c b/bin/tests/nxtify.c index 9e62dfbcd2..0decc97101 100644 --- a/bin/tests/nxtify.c +++ b/bin/tests/nxtify.c @@ -33,13 +33,13 @@ static isc_mem_t *mctx = NULL; static inline void -fatal(char *message) { +fatal(const char *message) { fprintf(stderr, "%s\n", message); exit(1); } static inline void -check_result(isc_result_t result, char *message) { +check_result(isc_result_t result, const char *message) { if (result != ISC_R_SUCCESS) { fprintf(stderr, "%s: %s\n", message, isc_result_totext(result)); diff --git a/bin/tests/omapi_test.c b/bin/tests/omapi_test.c index b4b8f38d33..e134db23ac 100644 --- a/bin/tests/omapi_test.c +++ b/bin/tests/omapi_test.c @@ -405,7 +405,7 @@ do_connect(const char *host, int port) { omapi_object_t *omapi_client = NULL; client_object_t *client = NULL; isc_result_t result; - char *key; + const char *key; RUNTIME_CHECK(omapi_object_register(&client_type, "client", client_setvalue, diff --git a/bin/tests/printmsg.c b/bin/tests/printmsg.c index 2aa15ffbfd..922718af89 100644 --- a/bin/tests/printmsg.c +++ b/bin/tests/printmsg.c @@ -25,7 +25,7 @@ #include "printmsg.h" -static char *opcodetext[] = { +static const char *opcodetext[] = { "QUERY", "IQUERY", "STATUS", @@ -44,7 +44,7 @@ static char *opcodetext[] = { "RESERVED15" }; -static char *rcodetext[] = { +static const char *rcodetext[] = { "NOERROR", "FORMERR", "SERVFAIL", @@ -65,7 +65,9 @@ static char *rcodetext[] = { }; static isc_result_t -printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name) { +printsection(dns_message_t *msg, dns_section_t sectionid, + const char *section_name) +{ dns_name_t *name, *print_name; dns_rdataset_t *rdataset; isc_buffer_t target; @@ -131,7 +133,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name) { static isc_result_t printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, dns_name_t *owner, - char *set_name) + const char *set_name) { isc_buffer_t target; isc_result_t result; diff --git a/bin/tests/rbt/t_rbt.c b/bin/tests/rbt/t_rbt.c index 44e7777c9e..95e3730ccb 100644 --- a/bin/tests/rbt/t_rbt.c +++ b/bin/tests/rbt/t_rbt.c @@ -411,7 +411,7 @@ test_rbt_gen(char *filename, char *command, char *testname, } static int -test_dns_rbt_x(char *filename) { +test_dns_rbt_x(const char *filename) { FILE *fp; char *p; int line; @@ -471,7 +471,7 @@ test_dns_rbt_x(char *filename) { } -static char *a1 = "dns_rbt_create creates a rbt and returns " +static const char *a1 = "dns_rbt_create creates a rbt and returns " "ISC_R_SUCCESS on success"; static void @@ -483,7 +483,7 @@ t1() { t_result(result); } -static char *a2 = "dns_rbt_addname adds a name to a database and " +static const char *a2 = "dns_rbt_addname adds a name to a database and " "returns ISC_R_SUCCESS on success"; static void @@ -495,7 +495,7 @@ t2() { t_result(result); } -static char *a3 = "when name already exists, dns_rbt_addname() " +static const char *a3 = "when name already exists, dns_rbt_addname() " "returns ISC_R_EXISTS"; static void @@ -507,7 +507,7 @@ t3() { t_result(result); } -static char *a4 = "when name exists, dns_rbt_deletename() returns " +static const char *a4 = "when name exists, dns_rbt_deletename() returns " "ISC_R_SUCCESS"; static void @@ -519,7 +519,7 @@ t4() { t_result(result); } -static char *a5 = "when name does not exist, dns_rbt_deletename() " +static const char *a5 = "when name does not exist, dns_rbt_deletename() " "returns ISC_R_NOTFOUND"; static void t5() { @@ -530,7 +530,7 @@ t5() { t_result(result); } -static char *a6 = "when name exists and exactly matches the " +static const char *a6 = "when name exists and exactly matches the " "search name dns_rbt_findname() returns ISC_R_SUCCESS"; static void @@ -542,7 +542,7 @@ t6() { t_result(result); } -static char *a7 = "when a name does not exist, " +static const char *a7 = "when a name does not exist, " "dns_rbt_findname returns ISC_R_NOTFOUND"; static void @@ -554,7 +554,7 @@ t7() { t_result(result); } -static char *a8 = "when a superdomain is found with data matching name, " +static const char *a8 = "when a superdomain is found with data matching name, " "dns_rbt_findname returns DNS_R_PARTIALMATCH"; static void @@ -567,7 +567,7 @@ t8() { } -static char *a9 = "a call to dns_rbtnodechain_init(chain, mctx) " +static const char *a9 = "a call to dns_rbtnodechain_init(chain, mctx) " "initializes chain"; static int @@ -895,7 +895,7 @@ t_dns_rbtnodechain_init(char *dbfile, char *findname, } static int -test_dns_rbtnodechain_init(char *filename) { +test_dns_rbtnodechain_init(const char *filename) { FILE *fp; char *p; int line; @@ -1057,7 +1057,7 @@ t_dns_rbtnodechain_first(char *dbfile, char *expected_firstname, } static int -test_dns_rbtnodechain_first(char *filename) { +test_dns_rbtnodechain_first(const char *filename) { FILE *fp; char *p; int line; @@ -1120,7 +1120,7 @@ test_dns_rbtnodechain_first(char *filename) { return(result); } -static char *a10 = "a call to " +static const char *a10 = "a call to " "dns_rbtnodechain_first(chain, rbt, name, origin) " "sets name to point to the root of the tree, " "origin to point to the origin, " @@ -1222,7 +1222,7 @@ t_dns_rbtnodechain_last(char *dbfile, char *expected_lastname, } static int -test_dns_rbtnodechain_last(char *filename) { +test_dns_rbtnodechain_last(const char *filename) { FILE *fp; char *p; int line; @@ -1285,7 +1285,7 @@ test_dns_rbtnodechain_last(char *filename) { return(result); } -static char *a11 = "a call to " +static const char *a11 = "a call to " "dns_rbtnodechain_last(chain, rbt, name, origin) " "sets name to point to the last node of the megatree, " "origin to the name of the level above it, " @@ -1401,7 +1401,7 @@ t_dns_rbtnodechain_next(char *dbfile, char *findname, } static int -test_dns_rbtnodechain_next(char *filename) { +test_dns_rbtnodechain_next(const char *filename) { FILE *fp; char *p; int line; @@ -1463,7 +1463,8 @@ test_dns_rbtnodechain_next(char *filename) { return(result); } -static char *a12 = "a call to dns_rbtnodechain_next(chain, name, origin) " +static const char *a12 = "a call to " + "dns_rbtnodechain_next(chain, name, origin) " "sets name to point to the next node of the tree " "and returns ISC_R_SUCCESS or " "DNS_R_NEWORIGIN on success"; @@ -1578,7 +1579,7 @@ t_dns_rbtnodechain_prev(char *dbfile, char *findname, char *prevname, } static int -test_dns_rbtnodechain_prev(char *filename) { +test_dns_rbtnodechain_prev(const char *filename) { FILE *fp; char *p; int line; @@ -1640,7 +1641,8 @@ test_dns_rbtnodechain_prev(char *filename) { return(result); } -static char *a13 = "a call to dns_rbtnodechain_prev(chain, name, origin) " +static const char *a13 = "a call to " + "dns_rbtnodechain_prev(chain, name, origin) " "sets name to point to the previous node of the tree " "and returns ISC_R_SUCCESS or " "DNS_R_NEWORIGIN on success"; diff --git a/bin/tests/rbt_test.c b/bin/tests/rbt_test.c index c7a77becb0..a299aba260 100644 --- a/bin/tests/rbt_test.c +++ b/bin/tests/rbt_test.c @@ -259,7 +259,8 @@ iterate(dns_rbt_t *rbt, isc_boolean_t forward) { int main (int argc, char **argv) { - char *command, *arg, *whitespace, buffer[1024]; + char *command, *arg, buffer[1024]; + const char *whitespace; dns_name_t *name, *foundname; dns_fixedname_t fixedname; dns_rbt_t *rbt; diff --git a/bin/tests/shutdown_test.c b/bin/tests/shutdown_test.c index 338a20482b..ddb414edd0 100644 --- a/bin/tests/shutdown_test.c +++ b/bin/tests/shutdown_test.c @@ -129,7 +129,7 @@ tick(isc_task_t *task, isc_event_t *event) } static t_info * -new_task(isc_mem_t *mctx, char *name) { +new_task(isc_mem_t *mctx, const char *name) { t_info *ti; isc_time_t expires; isc_interval_t interval; @@ -141,7 +141,7 @@ new_task(isc_mem_t *mctx, char *name) { ti->timer = NULL; ti->ticks = 0; if (name != NULL) { - INSIST(strlen(name) < sizeof ti->name); + INSIST(strlen(name) < sizeof(ti->name)); strcpy(ti->name, name); } else sprintf(ti->name, "%d", task_count); diff --git a/bin/tests/sock_test.c b/bin/tests/sock_test.c index f577aa0bb2..b8cedc1c1e 100644 --- a/bin/tests/sock_test.c +++ b/bin/tests/sock_test.c @@ -324,8 +324,8 @@ main(int argc, char *argv[]) { /* * Queue up the first accept event. */ - RUNTIME_CHECK(isc_socket_accept(so1, t1, my_listen, - "so1") == ISC_R_SUCCESS); + RUNTIME_CHECK(isc_socket_accept(so1, t1, my_listen, "so1") + == ISC_R_SUCCESS); isc_time_settoepoch(&expires); isc_interval_set(&interval, 10, 0); ti1 = NULL; diff --git a/bin/tests/tasks/t_tasks.c b/bin/tests/tasks/t_tasks.c index 843e6e5d09..7bf2af699c 100644 --- a/bin/tests/tasks/t_tasks.c +++ b/bin/tests/tasks/t_tasks.c @@ -29,15 +29,15 @@ #include -isc_mem_t *mctx = NULL; - static void t1_callback(isc_task_t *task, isc_event_t *event) { int i; int j; + UNUSED(task); + j = 0; - task = task; + for (i = 0; i < 1000000; i++) j += 100; @@ -47,15 +47,16 @@ t1_callback(isc_task_t *task, isc_event_t *event) { static void t1_shutdown(isc_task_t *task, isc_event_t *event) { + UNUSED(task); - task = task; t_info("shutdown %s\n", event->ev_arg); isc_event_free(&event); } static void my_tick(isc_task_t *task, isc_event_t *event) { - task = task; + UNUSED(task); + t_info("%s\n", event->ev_arg); isc_event_free(&event); } @@ -67,6 +68,7 @@ my_tick(isc_task_t *task, isc_event_t *event) { static int t_tasks1(void) { char *p; + isc_mem_t *mctx; isc_taskmgr_t *manager; isc_task_t *task1; isc_task_t *task2; @@ -86,6 +88,7 @@ t_tasks1(void) { task2 = NULL; task3 = NULL; task4 = NULL; + mctx = NULL; workers = 2; p = t_getenv("ISC_TASK_WORKERS"); @@ -348,7 +351,7 @@ t_tasks1(void) { return(T_PASS); } -static char *a1 = "The task subsystem can create and manage tasks"; +static const char *a1 = "The task subsystem can create and manage tasks"; static void t1(void) { @@ -546,7 +549,7 @@ t_tasks2(void) { return(result); } -static char *a2 = "The task subsystem can create ISC_TASKS_MIN tasks"; +static const char *a2 = "The task subsystem can create ISC_TASKS_MIN tasks"; static void t2(void) { @@ -802,7 +805,7 @@ t_tasks3(void) { return(result); } -static char *a3 = "When isc_task_shutdown() is called, any shutdown " +static const char *a3 = "When isc_task_shutdown() is called, any shutdown " "events that have been requested via prior " "isc_task_onshutdown() calls are posted in " "LIFO order."; @@ -993,8 +996,9 @@ t_tasks4(void) { return(result); } -static char *a4 = "After isc_task_shutdown() has been called, any call to " - "isc_task_onshutdown() will return ISC_R_SHUTTINGDOWN."; +static const char *a4 = + "After isc_task_shutdown() has been called, any call to " + "isc_task_onshutdown() will return ISC_R_SHUTTINGDOWN."; static void t4(void) { @@ -1215,7 +1219,7 @@ t_tasks7(void) { return(result); } -static char *a7 = "A call to isc_task_create() creates a task that can " +static const char *a7 = "A call to isc_task_create() creates a task that can " "receive events."; static void @@ -1679,7 +1683,8 @@ t_tasks10(void) { return(result); } -static char *a10 = "A call to isc_task_purge(task, sender, type, tag) " +static const char *a10 = + "A call to isc_task_purge(task, sender, type, tag) " "purges all events of type 'type' and with tag 'tag' " "not marked as unpurgable from sender from the task's " "queue and returns the number of events purged."; @@ -1956,9 +1961,10 @@ t_tasks11(int purgable) { return(result); } -static char *a11 = "When the event is marked as purgable, a call to " - "isc_task_purgeevent(task, event) purges the event 'event' " - "from the task's queue and returns ISC_TRUE."; +static const char *a11 = + "When the event is marked as purgable, a call to " + "isc_task_purgeevent(task, event) purges the event 'event' " + "from the task's queue and returns ISC_TRUE."; static void t11(void) { @@ -1968,7 +1974,8 @@ t11(void) { t_result(result); } -static char *a12 = "When the event is not marked as purgable, a call to " +static const char *a12 = + "When the event is not marked as purgable, a call to " "isc_task_purgeevent(task, event) does not purge the " "event 'event' from the task's queue and returns " "ISC_FALSE."; @@ -1989,12 +1996,13 @@ t12(void) { static int T13_nfails; static int T13_nprobs; -static char *a13 = "A call to " - "isc_event_purgerange(task, sender, first, last, tag) " - "purges all events not marked unpurgable from " - "sender 'sender' and of type within the range 'first' " - "to 'last' inclusive from the task's event queue and " - "returns the number of tasks purged."; +static const char *a13 = + "A call to " + "isc_event_purgerange(task, sender, first, last, tag) " + "purges all events not marked unpurgable from " + "sender 'sender' and of type within the range 'first' " + "to 'last' inclusive from the task's event queue and " + "returns the number of tasks purged."; static int t_tasks13(void) { diff --git a/bin/tests/timer_test.c b/bin/tests/timer_test.c index 3a6261f1f3..8c8fe5f572 100644 --- a/bin/tests/timer_test.c +++ b/bin/tests/timer_test.c @@ -70,7 +70,7 @@ tick(isc_task_t *task, isc_event_t *event) { static void timeout(isc_task_t *task, isc_event_t *event) { char *name = event->ev_arg; - char *type; + const char *type; INSIST(event->ev_type == ISC_TIMEREVENT_IDLE || event->ev_type == ISC_TIMEREVENT_LIFE); diff --git a/bin/tests/timers/t_timers.c b/bin/tests/timers/t_timers.c index 76a6de2efd..1106919332 100644 --- a/bin/tests/timers/t_timers.c +++ b/bin/tests/timers/t_timers.c @@ -334,7 +334,7 @@ t_timers_x(isc_timertype_t timertype, isc_time_t *expires, #define T1_SECONDS 2 #define T1_NANOSECONDS 500000000 -static char *a1 = +static const char *a1 = "When type is isc_timertype_ticker, a call to isc_timer_create() " "creates a timer that posts an ISC_TIMEREVENT_TICK event to the " "specified task every 'interval' seconds and returns ISC_R_SUCCESS."; @@ -370,7 +370,7 @@ t1(void) { #define T2_SECONDS 5 #define T2_NANOSECONDS 300000000; -static char *a2 = +static const char *a2 = "When type is isc_timertype_once, a call to isc_timer_create() " "creates a timer that posts an ISC_TIMEEVENT_LIFE event to the " "specified task when the current time reaches or exceeds the time " @@ -487,7 +487,7 @@ t3_te(isc_task_t *task, isc_event_t *event) { #define T3_SECONDS 4 #define T3_NANOSECONDS 400000000 -static char *a3 = +static const char *a3 = "When type is isc_timertype_once, a call to isc_timer_create() " "creates a timer that posts an ISC_TIMEEVENT_IDLE event to the " "specified task when the timer has been idle for 'interval' seconds."; @@ -642,7 +642,7 @@ t4_te(isc_task_t *task, isc_event_t *event) { isc_event_free(&event); } -static char *a4 = +static const char *a4 = "A call to isc_timer_reset() changes the timer's type, expires and " "interval values to the given values."; @@ -1056,7 +1056,7 @@ t_timers5(void) { return(result); } -static char *a5 = +static const char *a5 = "When 'purge' is TRUE, a call to isc_timer_reset() purges any pending " "events from 'timer' from the task's event queue."; diff --git a/bin/tests/wire_test.c b/bin/tests/wire_test.c index f46501f020..e58437a37b 100644 --- a/bin/tests/wire_test.c +++ b/bin/tests/wire_test.c @@ -29,7 +29,7 @@ #include "printmsg.h" static inline void -CHECKRESULT(isc_result_t result, char *msg) { +CHECKRESULT(isc_result_t result, const char *msg) { if (result != ISC_R_SUCCESS) { printf("%s: %s\n", msg, dns_result_totext(result)); diff --git a/bin/tests/zone2_test.c b/bin/tests/zone2_test.c index 5d039c23ae..f7cfb86a39 100644 --- a/bin/tests/zone2_test.c +++ b/bin/tests/zone2_test.c @@ -286,7 +286,7 @@ query(dns_view_t *view) { int main(int argc, char **argv) { - char *conf = "named.conf"; + const char *conf = "named.conf"; isc_mem_t *mctx = NULL; dns_c_ctx_t *configctx = NULL; dns_view_t *view1 = NULL;