Commit 7efc8c3f authored by David Lawrence's avatar David Lawrence
Browse files

Megacommit of many files.

Mostly, several functions that take pointers as arguments, almost
always char * pointers, had those pointers qualified with "const".
Those that returned pointers to previously const-qualified arguments
had their return values qualified as const.  Some structure members
were qualified as const to retain that attribute from the variables
from which they were assigned.

Minor other ISC style cleanups.
parent a5e5d67f
......@@ -75,7 +75,7 @@ isc_boolean_t identify = ISC_FALSE,
defname = ISC_TRUE, aaonly = ISC_FALSE, tcpmode = ISC_FALSE;
static char *opcodetext[] = {
static const char *opcodetext[] = {
"QUERY",
"IQUERY",
"STATUS",
......@@ -94,7 +94,7 @@ static char *opcodetext[] = {
"RESERVED15"
};
static char *rcodetext[] = {
static const char *rcodetext[] = {
"NOERROR",
"FORMERR",
"SERVFAIL",
......@@ -494,6 +494,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
FILE *fp = NULL;
int bargc;
char *bargv[16];
char bargv0[sizeof("dig")];
int i, n;
int adrs[4];
int rc;
......@@ -1028,15 +1029,23 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
debug ("Batch line %s", batchline);
bargc = 1;
bargv[bargc] = strtok(batchline, " \t\r\n");
while ((bargv[bargc] != NULL) &&
(bargc < 14 )) {
while ((bargv[bargc] != NULL) && (bargc < 14 )) {
bargc++;
bargv[bargc] = strtok(NULL, " \t\r\n");
}
bargc--;
bargv[0] = "dig";
reorder_args(bargc+1, (char**)bargv);
parse_args(ISC_TRUE, bargc+1, (char**)bargv);
/*
* This silliness (instead of ``bargv[0] = "dig";'')
* dances around the const string issue. If in
* the future the 2nd argument to strncpy() is made
* longer than three characters, don't forget to resize
* bargv0 to accommodate it.
*/
strncpy(bargv0, "dig", sizeof(bargv0));
bargv[0] = bargv0;
reorder_args(bargc, (char **)bargv);
parse_args(ISC_TRUE, bargc, (char **)bargv);
}
}
if (lookup_list.head == NULL) {
......
......@@ -113,7 +113,7 @@ hex_dump(isc_buffer_t *b) {
void
fatal(char *format, ...) {
fatal(const char *format, ...) {
va_list args;
va_start(args, format);
......@@ -137,7 +137,7 @@ fatal(char *format, ...) {
#ifdef DEBUG
void
debug(char *format, ...) {
debug(const char *format, ...) {
va_list args;
va_start(args, format);
......@@ -147,13 +147,13 @@ debug(char *format, ...) {
}
#else
void
debug(char *format, ...) {
debug(const char *format, ...) {
UNUSED(format);
}
#endif
void
check_result(isc_result_t result, char *msg) {
check_result(isc_result_t result, const char *msg) {
if (result != ISC_R_SUCCESS) {
exitcode = 1;
fatal("%s: %s", msg, isc_result_totext(result));
......@@ -748,7 +748,7 @@ setup_lookup(dig_lookup_t *lookup) {
dig_server_t *serv;
dig_query_t *query;
isc_region_t r;
isc_textregion_t tr;
isc_constregion_t tr;
isc_buffer_t b;
char store[MXNAME];
......@@ -898,7 +898,7 @@ setup_lookup(dig_lookup_t *lookup) {
tr.base=lookup->rttext;
tr.length=strlen(lookup->rttext);
}
result = dns_rdatatype_fromtext(&rdtype, &tr);
result = dns_rdatatype_fromtext(&rdtype, (isc_textregion_t *)&tr);
check_result(result, "dns_rdatatype_fromtext");
if (rdtype == dns_rdatatype_axfr) {
lookup->doing_xfr = ISC_TRUE;
......@@ -914,7 +914,7 @@ setup_lookup(dig_lookup_t *lookup) {
tr.base=lookup->rctext;
tr.length=strlen(lookup->rctext);
}
result = dns_rdataclass_fromtext(&rdclass, &tr);
result = dns_rdataclass_fromtext(&rdclass, (isc_textregion_t *)&tr);
check_result(result, "dns_rdataclass_fromtext");
add_type(lookup->sendmsg, lookup->name, rdclass, rdtype);
......
......@@ -56,7 +56,7 @@ isc_boolean_t short_form = ISC_TRUE,
showallsoa = ISC_FALSE,
tcpmode = ISC_FALSE;
static char *opcodetext[] = {
static const char *opcodetext[] = {
"QUERY",
"IQUERY",
"STATUS",
......@@ -75,7 +75,7 @@ static char *opcodetext[] = {
"RESERVED15"
};
static char *rcodetext[] = {
static const char *rcodetext[] = {
"NOERROR",
"FORMERR",
"SERVFAIL",
......@@ -95,7 +95,7 @@ static char *rcodetext[] = {
"BADVERS"
};
static char *rtypetext[] = {
static const char *rtypetext[] = {
"zero", /* 0 */
"has address", /* 1 */
"name server", /* 2 */
......@@ -251,7 +251,7 @@ trying(int frmsize, char *frm, dig_lookup_t *lookup) {
}
static void
say_message(dns_name_t *name, char *msg, dns_rdata_t *rdata,
say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
dig_query_t *query)
{
isc_buffer_t *b = NULL, *b2 = NULL;
......@@ -280,8 +280,9 @@ say_message(dns_name_t *name, char *msg, dns_rdata_t *rdata,
static isc_result_t
printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name,
isc_boolean_t headers, dig_query_t *query)
printsection(dns_message_t *msg, dns_section_t sectionid,
const char *section_name, isc_boolean_t headers,
dig_query_t *query)
{
dns_name_t *name, *print_name;
dns_rdataset_t *rdataset;
......@@ -293,7 +294,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name,
char t[4096];
isc_boolean_t first;
isc_boolean_t no_rdata;
char *rtt;
const char *rtt;
if (sectionid == DNS_SECTION_QUESTION)
no_rdata = ISC_TRUE;
......@@ -349,11 +350,11 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name,
else if (rdata.type == 250)
rtt = "signature";
else
rtt="unknown";
rtt = "unknown";
say_message(print_name, rtt,
&rdata, query);
loopresult = dns_rdataset_next(
rdataset);
loopresult =
dns_rdataset_next(rdataset);
}
}
}
......@@ -378,7 +379,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, isc_boolean_t headers)
const char *set_name, isc_boolean_t headers)
{
isc_buffer_t target;
isc_result_t result;
......
......@@ -133,19 +133,21 @@ struct dig_searchlist {
ISC_LINK(dig_searchlist_t) link;
};
/* Routines in dighost.c */
/*
* Routines in dighost.c.
*/
void
get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr);
void
fatal(char *format, ...) ;
fatal(const char *format, ...);
void
debug(char *format, ...) ;
debug(const char *format, ...);
void
check_result(isc_result_t result, char *msg);
check_result(isc_result_t result, const char *msg);
isc_boolean_t
isclass(char *text) ;
isclass(char *text);
isc_boolean_t
istype(char *text) ;
istype(char *text);
void
setup_lookup(dig_lookup_t *lookup);
void
......@@ -162,13 +164,15 @@ void
setup_system(void);
void
free_lists(int exitcode);
dig_lookup_t
*requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
dig_lookup_t *
requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
/* Routines needed in dig.c and host.c */
/*
* Routines needed in dig.c and host.c.
*/
isc_result_t
printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) ;
printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers);
void
received(int bytes, int frmsize, char *frm, dig_query_t *query);
void
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
*/
/* $Id: dnssec-keygen.c,v 1.28 2000/06/01 02:32:12 bwelling Exp $ */
/* $Id: dnssec-keygen.c,v 1.29 2000/06/01 18:49:16 tale Exp $ */
#include <config.h>
......@@ -42,7 +42,7 @@
#define MAX_RSA 2048 /* XXX ogud update this when rsa library is updated */
char *program = "dnssec-keygen";
const char *program = "dnssec-keygen";
int verbose;
static isc_boolean_t
......
......@@ -41,7 +41,7 @@
#define BUFSIZE 2048
char *program = "dnssec-makekeyset";
const char *program = "dnssec-makekeyset";
int verbose;
typedef struct keynode keynode_t;
......@@ -62,23 +62,23 @@ static isc_stdtime_t
strtotime(char *str, isc_int64_t now, isc_int64_t base) {
isc_int64_t val, offset;
isc_result_t result;
char *endp = "";
char *endp;
if (str[0] == '+') {
offset = strtol(str + 1, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = base + offset;
}
else if (strncmp(str, "now+", 4) == 0) {
} else if (strncmp(str, "now+", 4) == 0) {
offset = strtol(str + 4, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = now + offset;
}
else {
} else {
result = dns_time64_fromtext(str, &val);
if (result != ISC_R_SUCCESS)
fatal("time %s must be numeric", str);
}
if (*endp != '\0')
fatal("time value %s is invalid", str);
return ((isc_stdtime_t) val);
}
......
......@@ -38,7 +38,7 @@
#include "dnssectool.h"
char *program = "dnssec-signkey";
const char *program = "dnssec-signkey";
int verbose;
#define BUFSIZE 2048
......
......@@ -45,7 +45,7 @@
#include "dnssectool.h"
char *program = "dnssec-signzone";
const char *program = "dnssec-signzone";
int verbose;
/*#define USE_ZONESTATUS*/
......@@ -1141,23 +1141,23 @@ static isc_stdtime_t
strtotime(char *str, isc_int64_t now, isc_int64_t base) {
isc_int64_t val, offset;
isc_result_t result;
char *endp = "";
char *endp;
if (str[0] == '+') {
offset = strtol(str + 1, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = base + offset;
}
else if (strncmp(str, "now+", 4) == 0) {
} else if (strncmp(str, "now+", 4) == 0) {
offset = strtol(str + 4, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = now + offset;
}
else {
} else {
result = dns_time64_fromtext(str, &val);
if (result != ISC_R_SUCCESS)
fatal("time %s must be numeric", str);
}
if (*endp != '\0')
fatal("time value %s is invalid", str);
return ((isc_stdtime_t) val);
}
......
......@@ -32,10 +32,10 @@
#include "dnssectool.h"
extern int verbose;
extern char *program;
extern const char *program;
void
fatal(char *format, ...) {
fatal(const char *format, ...) {
va_list args;
fprintf(stderr, "%s: ", program);
......@@ -47,7 +47,7 @@ fatal(char *format, ...) {
}
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: %s\n", program, message,
isc_result_totext(result));
......@@ -140,8 +140,8 @@ setup_logging(int verbose, isc_mem_t *mctx, isc_log_t **logp) {
dns_log_init(log);
dns_log_setcontext(log);
isc_log_settag(logconfig, program);
RUNTIME_CHECK(isc_log_settag(logconfig, program) == ISC_R_SUCCESS);
/*
* Set up a channel similar to default_stderr except:
* - the logging level is passed in
......
......@@ -16,14 +16,27 @@
*/
#ifndef DNSSECTOOL_H
#define DNSSECTOOL_H
#define DNSSECTOOL_H 1
void fatal(char *format, ...);
void check_result(isc_result_t result, char *message);
void vbprintf(int level, const char *fmt, ...);
char *nametostr(dns_name_t *name);
char *typetostr(const dns_rdatatype_t type);
char *algtostr(const dns_secalg_t alg);
void setup_logging(int verbose, isc_mem_t *mctx, isc_log_t **logp);
void
fatal(const char *format, ...);
#endif
void
check_result(isc_result_t result, const char *message);
void
vbprintf(int level, const char *fmt, ...);
char *
nametostr(dns_name_t *name);
char *
typetostr(const dns_rdatatype_t type);
char *
algtostr(const dns_secalg_t alg);
void
setup_logging(int verbose, isc_mem_t *mctx, isc_log_t **logp);
#endif /* DNSSEC_DNSSECTOOL_H */
......@@ -48,7 +48,7 @@ EXTERN dns_dispatchmgr_t * ns_g_dispatchmgr INIT(NULL);
EXTERN isc_timermgr_t * ns_g_timermgr INIT(NULL);
EXTERN isc_socketmgr_t * ns_g_socketmgr INIT(NULL);
EXTERN omapi_object_t * ns_g_omapimgr INIT(NULL);
EXTERN char * ns_g_version INIT(VERSION);
EXTERN const char * ns_g_version INIT(VERSION);
EXTERN in_port_t ns_g_port INIT(53);
EXTERN ns_server_t * ns_g_server INIT(NULL);
......@@ -75,7 +75,7 @@ EXTERN const char * ns_g_chrootdir INIT(NULL);
EXTERN isc_boolean_t ns_g_foreground INIT(ISC_FALSE);
EXTERN isc_boolean_t ns_g_logstderr INIT(ISC_FALSE);
EXTERN char * ns_g_defaultpidfile INIT(NS_LOCALSTATEDIR
EXTERN const char * ns_g_defaultpidfile INIT(NS_LOCALSTATEDIR
"/run/named.pid");
EXTERN const char * ns_g_username INIT(NULL);
......
......@@ -165,7 +165,7 @@ ns_interfacemgr_shutdown(ns_interfacemgr_t *mgr) {
static isc_result_t
ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
char *name, ns_interface_t **ifpret)
const char *name, ns_interface_t **ifpret)
{
ns_interface_t *ifp;
isc_result_t result;
......@@ -322,7 +322,7 @@ ns_interface_accepttcp(ns_interface_t *ifp) {
static isc_result_t
ns_interface_setup(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
char *name, ns_interface_t **ifpret)
const char *name, ns_interface_t **ifpret)
{
isc_result_t result;
ns_interface_t *ifp = NULL;
......
......@@ -70,7 +70,7 @@ channel_fromconf(dns_c_logchan_t *cchan, isc_logconfig_t *lctx) {
isc_result_t result;
isc_logdestination_t dest;
unsigned int type;
int flags = 0;
unsigned int flags = 0;
int level;
type = ISC_LOG_TONULL;
......
......@@ -43,8 +43,8 @@
#include <named/server.h>
#include <named/main.h>
static isc_boolean_t want_stats = ISC_FALSE;
static char * program_name = "named";
static isc_boolean_t want_stats = ISC_FALSE;
static const char * program_name = "named";
void
ns_main_earlyfatal(const char *format, ...) {
......@@ -70,7 +70,9 @@ ns_main_earlyfatal(const char *format, ...) {
}
static void
assertion_failed(char *file, int line, isc_assertiontype_t type, char *cond) {
assertion_failed(const char *file, int line, isc_assertiontype_t type,
const char *cond)
{
/*
* Handle assertion failures.
*/
......@@ -101,7 +103,9 @@ assertion_failed(char *file, int line, isc_assertiontype_t type, char *cond) {
}
static void
library_fatal_error(char *file, int line, char *format, va_list args) {
library_fatal_error(const char *file, int line, const char *format,
va_list args)
{
/*
* Handle isc_error_fatal() calls from our libraries.
*/
......@@ -135,7 +139,9 @@ library_fatal_error(char *file, int line, char *format, va_list args) {
}
static void
library_unexpected_error(char *file, int line, char *format, va_list args) {
library_unexpected_error(const char *file, int line, const char *format,
va_list args)
{
/*
* Handle isc_error_unexpected() calls from our libraries.
*/
......
......@@ -718,7 +718,7 @@ query_isduplicate(ns_client_t *client, dns_name_t *name,
}
static isc_result_t
query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
query_addadditional(void *arg, dns_name_t *name, int qtype) {
ns_client_t *client = arg;
isc_result_t result, eresult;
dns_dbnode_t *node, *znode;
......
......@@ -86,8 +86,11 @@ typedef struct {
dns_aclconfctx_t *aclconf;
} ns_load_t;
static void fatal(char *msg, isc_result_t result);
static void ns_server_reload(isc_task_t *task, isc_event_t *event);
static void
fatal(const char *msg, isc_result_t result);
static void
ns_server_reload(isc_task_t *task, isc_event_t *event);
static isc_result_t
ns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx,
......@@ -705,7 +708,13 @@ create_version_view(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr, dns_view_t **viewp)
result = dns_c_ctx_getversion(cctx, &versiontext);
if (result != ISC_R_SUCCESS)
versiontext = ns_g_version;
/*
* Removing the const qualifier from ns_g_version is ok
* because the resulting string is not modified, only
* copied into a new buffer.
*/
DE_CONST(ns_g_version, versiontext);
len = strlen(versiontext);
if (len > 255)
len = 255; /* Silently truncate. */
......@@ -789,7 +798,7 @@ find_or_create_view(dns_c_view_t *cview, dns_viewlist_t *viewlist,
dns_view_t **viewp)
{
isc_result_t result;
char *viewname;
const char *viewname;
dns_rdataclass_t viewclass;
dns_view_t *view = NULL;
......@@ -1325,11 +1334,11 @@ load_configuration(const char *filename, ns_server_t *server,
"now using logging configuration from "
"config file");
if (dns_c_ctx_getpidfilename(cctx, &pidfilename) ==
ISC_R_NOTFOUND)
pidfilename = ns_g_defaultpidfile;
ns_os_writepidfile(pidfilename);
if (dns_c_ctx_getpidfilename(cctx, &pidfilename) != ISC_R_NOTFOUND)
ns_os_writepidfile(pidfilename);
else
ns_os_writepidfile(ns_g_defaultpidfile);
dns_aclconfctx_destroy(&aclconfctx);
dns_c_ctx_delete(&cctx);
......@@ -1566,7 +1575,7 @@ ns_server_destroy(ns_server_t **serverp) {
}
static void
fatal(char *msg, isc_result_t result) {
fatal(const char *msg, isc_result_t result) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
ISC_LOG_CRITICAL, "%s: %s", msg,
isc_result_totext(result));
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: xfrout.c,v 1.64 2000/05/30 23:14:48 bwelling Exp $ */
/* $Id: xfrout.c,v 1.65 2000/06/01 18:44:26 tale Exp $ */
#include <config.h>
......@@ -766,7 +766,7 @@ static void
xfrout_senddone(isc_task_t *task, isc_event_t *event);
static void
xfrout_fail(xfrout_ctx_t *xfr, isc_result_t result, char *msg);
xfrout_fail(xfrout_ctx_t *xfr, isc_result_t result, const char *msg);
static void
xfrout_maybe_destroy(xfrout_ctx_t *xfr);
......@@ -803,7 +803,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
dns_rdataset_t *soa_rdataset;
dns_rdata_t soa_rdata;
isc_boolean_t have_soa = ISC_FALSE;
char *mnemonic = NULL;
const char *mnemonic = NULL;
isc_mem_t *mctx = client->mctx;
dns_message_t *request = client->message;
xfrout_ctx_t *xfr = NULL;
......@@ -1469,7 +1469,7 @@ xfrout_senddone(isc_task_t *task, isc_event_t *event) {
}
static void
xfrout_fail(xfrout_ctx_t *xfr, isc_result_t result, char *msg) {
xfrout_fail(xfrout_ctx_t *xfr, isc_result_t result, const char *msg) {
xfr->shuttingdown = ISC_TRUE;
xfrout_log(xfr, ISC_LOG_ERROR, "%s: %s",
msg, isc_result_totext(result));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment