Commit 6d12fdf9 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.

The macro DE_CONST is used to deal with a handful of very special
places where something is qualified as const but really needs to have
its const qualifier removed.

rdata.c now defines macros for the prototypes of the basic rdata functions,
and all of the lib/dns/rdata/**/*.c files now use them.

Some minor integer-compatibility issues.  (IE, ~0x03 is a signed int,
so assigning it to an unsigned int should use a cast.  The type of an
enum member is int, so there are some conversion issues there, too.)

A pointers-to-function should not be cast to a pointer-to-object.

Variables should not be named for C reserved identifiers.

One or two set-but-not-used variables removed.

Minor other ISC style cleanups.
parent 8612a0d5
......@@ -414,8 +414,7 @@ static isc_result_t dbfind_a6(dns_adbname_t *, isc_stdtime_t);
static void
DP(int level, char *format, ...)
{
DP(int level, const char *format, ...) {
va_list args;
va_start(args, format);
......@@ -3005,7 +3004,7 @@ print_namehook_list(FILE *f, dns_adbname_t *n) {
}
static inline void
print_fetch(FILE *f, dns_adbfetch_t *ft, char *type) {
print_fetch(FILE *f, dns_adbfetch_t *ft, const char *type) {
fprintf(f, "\t\tFetch(%s): %p -> { nh %p, entry %p, fetch %p }\n",
type, ft, ft->namehook, ft->entry, ft->fetch);
}
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cache.c,v 1.21 2000/05/08 14:34:26 tale Exp $ */
/* $Id: cache.c,v 1.22 2000/06/01 18:25:25 tale Exp $ */
#include <config.h>
......@@ -120,7 +120,7 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event);
isc_result_t
dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, dns_rdataclass_t rdclass,
char *db_type, unsigned int db_argc, char **db_argv,
const char *db_type, unsigned int db_argc, char **db_argv,
dns_cache_t **cachep)
{
isc_result_t result;
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: callbacks.c,v 1.7 2000/05/08 14:34:27 tale Exp $ */
/* $Id: callbacks.c,v 1.8 2000/06/01 18:25:26 tale Exp $ */
#include <config.h>
......@@ -24,14 +24,17 @@
#include <dns/callbacks.h>
#include <dns/log.h>
static void stdio_error_warn_callback(dns_rdatacallbacks_t *, char *, ...);
static void
stdio_error_warn_callback(dns_rdatacallbacks_t *, const char *, ...);
/*
* Private
*/
static void
stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks,
const char *fmt, ...)
{
va_list ap;
UNUSED(callbacks);
......@@ -43,7 +46,7 @@ stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
}
static void
isclog_error_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
va_list ap;
UNUSED(callbacks);
......@@ -56,7 +59,7 @@ isclog_error_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
}
static void
isclog_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
va_list ap;
UNUSED(callbacks);
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confcommon.c,v 1.29 2000/05/31 13:09:55 brister Exp $ */
/* $Id: confcommon.c,v 1.30 2000/06/01 18:25:42 tale Exp $ */
#include <config.h>
......@@ -716,7 +716,7 @@ dns_c_charptoname(isc_mem_t *mem, const char *keyval, dns_name_t **name) {
dns_name_setbuffer(&newkey, b1);
isc_buffer_init(&b2, (char *)keyval, len);
isc_buffer_init(&b2, keyval, len);
isc_buffer_add(&b2, len);
res = dns_name_fromtext(&newkey, &b2, NULL, ISC_FALSE, NULL);
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confndc.c,v 1.15 2000/05/24 15:07:58 tale Exp $ */
/* $Id: confndc.c,v 1.16 2000/06/01 18:25:43 tale Exp $ */
/*
** options {
......@@ -81,8 +81,8 @@ typedef struct {
} ndcpcontext;
struct keywordtoken {
char *token;
int yaccval;
const char *token;
const int yaccval;
};
......@@ -110,7 +110,7 @@ struct keywordtoken {
#define L_STRING 20
#define L_INTEGER 21
static struct keywordtoken keyword_tokens [] = {
static struct keywordtoken keyword_tokens[] = {
{ "{", L_LBRACE },
{ "}", L_RBRACE },
{ ";", L_EOS },
......@@ -142,40 +142,51 @@ static struct keywordtoken misc_tokens[] = {
static isc_result_t parse_file(ndcpcontext *pctx,
dns_c_ndcctx_t **context);
static isc_result_t parse_statement(ndcpcontext *pctx);
static isc_result_t parse_options(ndcpcontext *pctx, dns_c_ndcopts_t **opts);
static isc_result_t parse_serverstmt(ndcpcontext *pctx,
dns_c_ndcserver_t **server);
static isc_result_t parse_keystmt(ndcpcontext *pctx, dns_c_kdeflist_t *keys);
static isc_result_t
parse_file(ndcpcontext *pctx, dns_c_ndcctx_t **context);
static isc_result_t
parse_statement(ndcpcontext *pctx);
static isc_result_t
parse_options(ndcpcontext *pctx, dns_c_ndcopts_t **opts);
static isc_result_t
parse_serverstmt(ndcpcontext *pctx, dns_c_ndcserver_t **server);
static isc_result_t
parse_keystmt(ndcpcontext *pctx, dns_c_kdeflist_t *keys);
static const char * keyword2str(isc_int32_t val);
static isc_boolean_t eat(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t eat_eos(ndcpcontext *pctx);
static isc_boolean_t eat_lbrace(ndcpcontext *pctx);
static isc_boolean_t eat_rbrace(ndcpcontext *pctx);
static const char *
keyword2str(isc_int32_t val);
static isc_boolean_t
eat(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t
eat_eos(ndcpcontext *pctx);
static isc_boolean_t
eat_lbrace(ndcpcontext *pctx);
static isc_boolean_t
eat_rbrace(ndcpcontext *pctx);
static isc_boolean_t looking_at(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t looking_at_anystring(ndcpcontext *pctx);
static isc_boolean_t
looking_at(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t
looking_at_anystring(ndcpcontext *pctx);
static isc_result_t parser_setup(ndcpcontext *pctx, isc_mem_t *mem,
const char *filename);
static void parser_complain(isc_boolean_t is_warning,
isc_boolean_t print_last_token, ndcpcontext *pctx,
const char *format, va_list args);
static void parser_error(ndcpcontext *pctx, isc_boolean_t lasttoken,
const char *fmt, ...);
static void parser_warn(ndcpcontext *pctx, isc_boolean_t lasttoken,
const char *fmt, ...);
static isc_boolean_t is_ip6addr(const char *string, struct in6_addr *addr);
static isc_boolean_t is_ip4addr(const char *string, struct in_addr *addr);
static isc_result_t getnexttoken(ndcpcontext *pctx);
static void syntax_error(ndcpcontext *pctx, isc_uint32_t keyword);
static isc_result_t
parser_setup(ndcpcontext *pctx, isc_mem_t *mem, const char *filename);
static void
parser_complain(isc_boolean_t is_warning, isc_boolean_t print_last_token,
ndcpcontext *pctx, const char *format, va_list args);
static void
parser_error(ndcpcontext *pctx, isc_boolean_t lasttoken, const char *fmt, ...);
static void
parser_warn(ndcpcontext *pctx, isc_boolean_t lasttoken, const char *fmt, ...);
static isc_boolean_t
is_ip6addr(const char *string, struct in6_addr *addr);
static isc_boolean_t
is_ip4addr(const char *string, struct in_addr *addr);
static isc_result_t
getnexttoken(ndcpcontext *pctx);
static void
syntax_error(ndcpcontext *pctx, isc_uint32_t keyword);
/* *********************************************************************** */
......@@ -1400,7 +1411,7 @@ parser_setup(ndcpcontext *pctx, isc_mem_t *mem, const char *filename) {
ISC_LEXCOMMENT_CPLUSPLUS |
ISC_LEXCOMMENT_SHELL));
result = isc_lex_openfile(pctx->thelexer, (char *)filename);
result = isc_lex_openfile(pctx->thelexer, filename);
if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG, ISC_LOG_CRITICAL,
......
......@@ -16,7 +16,7 @@
* SOFTWARE.
*/
/* $Id: confparser.y,v 1.85 2000/05/31 13:09:57 brister Exp $ */
/* $Id: confparser.y,v 1.86 2000/06/01 18:25:45 tale Exp $ */
#include <config.h>
......@@ -126,7 +126,7 @@ static void parser_complain(isc_boolean_t is_warning,
isc_boolean_t last_token,
const char *format, va_list args);
static isc_boolean_t unit_to_uint32(char *in, isc_uint32_t *out);
static char * token_to_keyword(int token);
static const char * token_to_keyword(int token);
static void yyerror(const char *);
static dns_peerlist_t *currentpeerlist(dns_c_ctx_t *cfg,
isc_boolean_t createIfNeeded);
......@@ -2429,7 +2429,7 @@ category_name: any_string
}
| L_DEFAULT
{
char *name = token_to_keyword(L_DEFAULT);
const char *name = token_to_keyword(L_DEFAULT);
REQUIRE(name != NULL);
......@@ -2437,7 +2437,7 @@ category_name: any_string
}
| L_NOTIFY
{
char *name = token_to_keyword(L_NOTIFY);
const char *name = token_to_keyword(L_NOTIFY);
REQUIRE(name != NULL);
......@@ -4881,7 +4881,7 @@ static int lasttoken;
*/
struct token
{
char *token;
const char *token;
int yaccval;
};
......@@ -5160,7 +5160,7 @@ dns_c_parse_namedconf(const char *filename, isc_mem_t *mem,
ISC_LEXCOMMENT_CPLUSPLUS |
ISC_LEXCOMMENT_SHELL));
res = isc_lex_openfile(mylexer, (char *)filename); /* remove const */
res = isc_lex_openfile(mylexer, filename);
if (res != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG, ISC_LOG_CRITICAL,
......@@ -5324,9 +5324,11 @@ yylex(void)
static char *
token_to_text(int token, YYSTYPE lval) {
static char buffer[1024];
char *tk;
const char *tk;
/* Yacc keeps token numbers above 128, it seems. */
/*
* Yacc keeps token numbers above 128, it seems.
*/
if (token < 128) {
if (token == 0)
strncpy(buffer, "<end of file>", sizeof buffer);
......@@ -5383,9 +5385,8 @@ token_to_text(int token, YYSTYPE lval) {
return (buffer);
}
static char *
token_to_keyword(int token)
{
static const char *
token_to_keyword(int token) {
int i;
for (i = 0 ; keyword_tokens[i].token != NULL ; i++) {
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confrrset.c,v 1.13 2000/05/08 14:35:35 tale Exp $ */
/* $Id: confrrset.c,v 1.14 2000/06/01 18:25:46 tale Exp $ */
#include <config.h>
......@@ -82,9 +82,9 @@ dns_c_rrsolist_new(isc_mem_t *mem, dns_c_rrsolist_t **rval) {
}
isc_result_t
dns_c_rrso_new(isc_mem_t *mem, dns_c_rrso_t **res,
dns_rdataclass_t oclass,
dns_rdatatype_t otype, char *name, dns_c_ordering_t ordering)
dns_c_rrso_new(isc_mem_t *mem, dns_c_rrso_t **res, dns_rdataclass_t oclass,
dns_rdatatype_t otype, const char *name,
dns_c_ordering_t ordering)
{
dns_c_rrso_t *newo;
......
......@@ -35,7 +35,7 @@
***/
typedef struct {
char * name;
const char * name;
isc_result_t (*create)(isc_mem_t *mctx, dns_name_t *name,
isc_boolean_t cache,
dns_rdataclass_t rdclass,
......@@ -67,7 +67,7 @@ static impinfo_t implementations[] = {
***/
isc_result_t
dns_db_create(isc_mem_t *mctx, char *db_type, dns_name_t *origin,
dns_db_create(isc_mem_t *mctx, const char *db_type, dns_name_t *origin,
isc_boolean_t cache, dns_rdataclass_t rdclass,
unsigned int argc, char *argv[], dns_db_t **dbp)
{
......
......@@ -16,7 +16,7 @@
*/
/*
* $Id: dnssec.c,v 1.40 2000/05/30 22:30:39 bwelling Exp $
* $Id: dnssec.c,v 1.41 2000/06/01 18:25:29 tale Exp $
* Principal Author: Brian Wellington
*/
......@@ -92,7 +92,8 @@ digest_callback(void *arg, isc_region_t *data) {
*/
static int
rdata_compare_wrapper(const void *rdata1, const void *rdata2) {
return dns_rdata_compare((dns_rdata_t *)rdata1, (dns_rdata_t *)rdata2);
return (dns_rdata_compare((const dns_rdata_t *)rdata1,
(const dns_rdata_t *)rdata2));
}
/*
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: gen.c,v 1.46 2000/05/09 22:22:11 tale Exp $ */
/* $Id: gen.c,v 1.47 2000/06/01 18:25:30 tale Exp $ */
#include <config.h>
......@@ -151,13 +151,21 @@ struct ttnam {
unsigned int sorted;
} typenames[256];
char * upper(char *);
char * funname(char *, char *);
void doswitch(char *, char *, char *, char *, char *, char *);
void dodecl(char *, char *, char *);
void add(int, char *, int, char *, char *);
void sd(int, char *, char *, char);
void insert_into_typenames(int, char *, char *);
char *
upper(char *);
char *
funname(char *, char *);
void
doswitch(const char *, const char *, const char *, const char *,
const char *, const char *);
void
dodecl(char *, char *, char *);
void
add(int, const char *, int, const char *, const char *);
void
sd(int, const char *, const char *, char);
void
insert_into_typenames(int, const char *, const char *);
/*
* If you use more than 10 of these in, say, a printf(), you'll have problems.
......@@ -195,15 +203,15 @@ funname(char *s, char *buf) {
}
void
doswitch(char *name, char *function, char *args,
char *tsw, char *csw, char *res)
doswitch(const char *name, const char *function, const char *args,
const char *tsw, const char *csw, const char *res)
{
struct tt *tt;
int first = 1;
int lasttype = 0;
int subswitch = 0;
char buf1[11], buf2[11];
char *result = " result =";
const char *result = " result =";
if (res == NULL)
result = "";
......@@ -286,8 +294,7 @@ dodecl(char *type, char *function, char *args) {
}
void
insert_into_typenames(int type, char *typename, char *attr)
{
insert_into_typenames(int type, const char *typename, const char *attr) {
struct ttnam *ttn;
int c;
char tmp[256];
......@@ -335,7 +342,9 @@ insert_into_typenames(int type, char *typename, char *attr)
}
void
add(int rdclass, char *classname, int type, char *typename, char *dirname) {
add(int rdclass, const char *classname, int type, const char *typename,
const char *dirname)
{
struct tt *newtt = (struct tt *)malloc(sizeof *newtt);
struct tt *tt, *oldtt;
struct cc *newcc;
......@@ -409,7 +418,7 @@ add(int rdclass, char *classname, int type, char *typename, char *dirname) {
}
void
sd(int rdclass, char *classname, char *dirname, char filetype) {
sd(int rdclass, const char *classname, const char *dirname, char filetype) {
char buf[sizeof "0123456789_65535.h"];
char fmt[sizeof "%10[-0-9a-z]_%d.h"];
int type;
......@@ -436,8 +445,7 @@ sd(int rdclass, char *classname, char *dirname, char filetype) {
}
static unsigned int
HASH(char *string)
{
HASH(char *string) {
unsigned int n;
unsigned char a, b;
......@@ -617,7 +625,7 @@ main(int argc, char **argv) {
insert_into_typenames(255, "any", METAQUESTIONONLY);
printf("\ntypedef struct {\n");
printf("\tchar *name;\n");
printf("\tconst char *name;\n");
printf("\tunsigned int flags;\n");
printf("} typeattr_t;\n");
printf("static typeattr_t typeattr[] = {\n");
......
......@@ -62,7 +62,7 @@ ISC_LANG_BEGINDECLS
isc_result_t
dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, dns_rdataclass_t rdclass,
char *db_type, unsigned int db_argc, char **db_argv,
const char *db_type, unsigned int db_argc, char **db_argv,
dns_cache_t **cachep);
/*
* Create a new DNS cache.
......
......@@ -40,11 +40,11 @@ struct dns_rdatacallbacks {
/*
* dns_load_master / dns_rdata_fromtext call this to issue a error.
*/
void (*error)(struct dns_rdatacallbacks *, char *, ...);
void (*error)(struct dns_rdatacallbacks *, const char *, ...);
/*
* dns_load_master / dns_rdata_fromtext call this to issue a warning.
*/
void (*warn)(struct dns_rdatacallbacks *, char *, ...);
void (*warn)(struct dns_rdatacallbacks *, const char *, ...);
/*
* Private data handles for use by the above callback functions.
*/
......
......@@ -110,7 +110,8 @@ dns_c_rrsolist_append(dns_c_rrsolist_t *dest, dns_c_rrsolist_t *src);
isc_result_t
dns_c_rrso_new(isc_mem_t *mem, dns_c_rrso_t **res, dns_rdataclass_t oclass,
dns_rdatatype_t otype, char *name, dns_c_ordering_t ordering);
dns_rdatatype_t otype, const char *name,
dns_c_ordering_t ordering);
isc_result_t
dns_c_rrso_delete(dns_c_rrso_t **order);
......
......@@ -189,7 +189,7 @@ struct dns_db {
***/
isc_result_t
dns_db_create(isc_mem_t *mctx, char *db_type, dns_name_t *origin,
dns_db_create(isc_mem_t *mctx, const char *db_type, dns_name_t *origin,
isc_boolean_t cache, dns_rdataclass_t rdclass,
unsigned int argc, char *argv[], dns_db_t **dbp);
/*
......
......@@ -100,7 +100,8 @@ ISC_LANG_BEGINDECLS
*** Properties
***/
dns_labeltype_t dns_label_type(dns_label_t *label);
dns_labeltype_t
dns_label_type(dns_label_t *label);
/*
* Get the type of 'label'.
*
......@@ -118,7 +119,8 @@ dns_labeltype_t dns_label_type(dns_label_t *label);
*** Bitstring Labels
***/
unsigned int dns_label_countbits(dns_label_t *label);
unsigned int
dns_label_countbits(dns_label_t *label);
/*
* The number of bits in a bitstring label.
*
......@@ -134,7 +136,8 @@ unsigned int dns_label_countbits(dns_label_t *label);
* The number of bits in the bitstring label.
*/
dns_bitlabel_t dns_label_getbit(dns_label_t *label, unsigned int n);
dns_bitlabel_t
dns_label_getbit(dns_label_t *label, unsigned int n);
/*
* The 'n'th most significant bit of 'label'.
*
......@@ -215,7 +218,8 @@ extern dns_name_t *dns_wildcardname;
*** Initialization
***/
void dns_name_init(dns_name_t *name, unsigned char *offsets);
void
dns_name_init(dns_name_t *name, unsigned char *offsets);
/*
* Initialize 'name'.
*
......@@ -234,7 +238,8 @@ void dns_name_init(dns_name_t *name, unsigned char *offsets);
* dns_name_countlabels(name) == 0
*/
void dns_name_invalidate(dns_name_t *name);
void
dns_name_invalidate(dns_name_t *name);
/*
* Make 'name' invalid.
*
......@@ -279,7 +284,7 @@ dns_name_setbuffer(dns_name_t *name, isc_buffer_t *buffer);
*/
isc_boolean_t
dns_name_hasbuffer(dns_name_t *name);
dns_name_hasbuffer(const dns_name_t *name);
/*
* Does 'name' have a dedicated buffer?
*
......@@ -296,7 +301,8 @@ dns_name_hasbuffer(dns_name_t *name);
*** Properties
***/
isc_boolean_t dns_name_isabsolute(dns_name_t *name);
isc_boolean_t
dns_name_isabsolute(const dns_name_t *name);
/*
* Does 'name' end in the root label?
*
......@@ -310,7 +316,8 @@ isc_boolean_t dns_name_isabsolute(dns_name_t *name);
* FALSE The last label in 'name' is not the root label.
*/
isc_boolean_t dns_name_iswildcard(dns_name_t *name);
isc_boolean_t
dns_name_iswildcard(const dns_name_t *name);
/*
* Is 'name' a wildcard name?
*
......@@ -324,7 +331,8 @@ isc_boolean_t dns_name_iswildcard(dns_name_t *name);
* FALSE The least significant label of 'name' is not '*'.
*/
isc_boolean_t dns_name_requiresedns(dns_name_t *name);
isc_boolean_t
dns_name_requiresedns(const dns_name_t *name);
/*
* Does 'name' require EDNS for transmission?
*
......@@ -338,7 +346,8 @@ isc_boolean_t dns_name_requiresedns(dns_name_t *name);
* FALSE The name does not require EDNS to be transmitted.
*/
unsigned int dns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive);
unsigned int
dns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive);
/*
* Provide a hash value for 'name'.
*
......@@ -357,7 +366,7 @@ unsigned int dns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive);
***/
dns_namereln_t
dns_name_fullcompare(dns_name_t *name1, dns_name_t *name2,
dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
int *orderp,
unsigned int *nlabelsp, unsigned int *nbitsp);
/*
......@@ -406,7 +415,7 @@ dns_name_fullcompare(dns_name_t *name1, dns_name_t *name2,
*/
int
dns_name_compare(dns_name_t *name1, dns_name_t *name2);
dns_name_compare(const dns_name_t *name1, const dns_name_t *name2);
/*
* Determine the relative ordering under the DNSSEC order relation of
* 'name1' and 'name2'.
......@@ -434,7 +443,7 @@ dns_name_compare(dns_name_t *name1, dns_name_t *name2);
*/
isc_boolean_t
dns_name_equal(dns_name_t *name1, dns_name_t *name2);
dns_name_equal(const dns_name_t *name1, const dns_name_t *name2);
/*
* Are 'name1' and 'name2' equal?
*
......@@ -462,7 +471,7 @@ dns_name_equal(dns_name_t *name1, dns_name_t *name2);
*/