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); ...@@ -414,8 +414,7 @@ static isc_result_t dbfind_a6(dns_adbname_t *, isc_stdtime_t);
static void static void
DP(int level, char *format, ...) DP(int level, const char *format, ...) {
{
va_list args; va_list args;
va_start(args, format); va_start(args, format);
...@@ -3005,7 +3004,7 @@ print_namehook_list(FILE *f, dns_adbname_t *n) { ...@@ -3005,7 +3004,7 @@ print_namehook_list(FILE *f, dns_adbname_t *n) {
} }
static inline void 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", fprintf(f, "\t\tFetch(%s): %p -> { nh %p, entry %p, fetch %p }\n",
type, ft, ft->namehook, ft->entry, ft->fetch); type, ft, ft->namehook, ft->entry, ft->fetch);
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* SOFTWARE. * 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> #include <config.h>
...@@ -120,7 +120,7 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event); ...@@ -120,7 +120,7 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event);
isc_result_t isc_result_t
dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, 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) dns_cache_t **cachep)
{ {
isc_result_t result; isc_result_t result;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* SOFTWARE. * 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> #include <config.h>
...@@ -24,14 +24,17 @@ ...@@ -24,14 +24,17 @@
#include <dns/callbacks.h> #include <dns/callbacks.h>
#include <dns/log.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 * Private
*/ */
static void 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; va_list ap;
UNUSED(callbacks); UNUSED(callbacks);
...@@ -43,7 +46,7 @@ stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) { ...@@ -43,7 +46,7 @@ stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
} }
static void static void
isclog_error_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) { isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
va_list ap; va_list ap;
UNUSED(callbacks); UNUSED(callbacks);
...@@ -56,7 +59,7 @@ isclog_error_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) { ...@@ -56,7 +59,7 @@ isclog_error_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
} }
static void static void
isclog_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) { isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
va_list ap; va_list ap;
UNUSED(callbacks); UNUSED(callbacks);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* SOFTWARE. * 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> #include <config.h>
...@@ -716,7 +716,7 @@ dns_c_charptoname(isc_mem_t *mem, const char *keyval, dns_name_t **name) { ...@@ -716,7 +716,7 @@ dns_c_charptoname(isc_mem_t *mem, const char *keyval, dns_name_t **name) {
dns_name_setbuffer(&newkey, b1); dns_name_setbuffer(&newkey, b1);
isc_buffer_init(&b2, (char *)keyval, len); isc_buffer_init(&b2, keyval, len);
isc_buffer_add(&b2, len); isc_buffer_add(&b2, len);
res = dns_name_fromtext(&newkey, &b2, NULL, ISC_FALSE, NULL); res = dns_name_fromtext(&newkey, &b2, NULL, ISC_FALSE, NULL);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* SOFTWARE. * 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 { ** options {
...@@ -81,8 +81,8 @@ typedef struct { ...@@ -81,8 +81,8 @@ typedef struct {
} ndcpcontext; } ndcpcontext;
struct keywordtoken { struct keywordtoken {
char *token; const char *token;
int yaccval; const int yaccval;
}; };
...@@ -110,7 +110,7 @@ struct keywordtoken { ...@@ -110,7 +110,7 @@ struct keywordtoken {
#define L_STRING 20 #define L_STRING 20
#define L_INTEGER 21 #define L_INTEGER 21
static struct keywordtoken keyword_tokens [] = { static struct keywordtoken keyword_tokens[] = {
{ "{", L_LBRACE }, { "{", L_LBRACE },
{ "}", L_RBRACE }, { "}", L_RBRACE },
{ ";", L_EOS }, { ";", L_EOS },
...@@ -142,40 +142,51 @@ static struct keywordtoken misc_tokens[] = { ...@@ -142,40 +142,51 @@ static struct keywordtoken misc_tokens[] = {
static isc_result_t parse_file(ndcpcontext *pctx, static isc_result_t
dns_c_ndcctx_t **context); 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_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 const char *
static isc_boolean_t eat(ndcpcontext *pctx, isc_uint32_t token); keyword2str(isc_int32_t val);
static isc_boolean_t eat_eos(ndcpcontext *pctx); static isc_boolean_t
static isc_boolean_t eat_lbrace(ndcpcontext *pctx); eat(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t eat_rbrace(ndcpcontext *pctx); 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
static isc_boolean_t looking_at_anystring(ndcpcontext *pctx); 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, static isc_result_t
const char *filename); parser_setup(ndcpcontext *pctx, isc_mem_t *mem, const char *filename);
static void parser_complain(isc_boolean_t is_warning, static void
isc_boolean_t print_last_token, ndcpcontext *pctx, parser_complain(isc_boolean_t is_warning, isc_boolean_t print_last_token,
const char *format, va_list args); ndcpcontext *pctx, const char *format, va_list args);
static void parser_error(ndcpcontext *pctx, isc_boolean_t lasttoken, static void
const char *fmt, ...); parser_error(ndcpcontext *pctx, isc_boolean_t lasttoken, const char *fmt, ...);
static void parser_warn(ndcpcontext *pctx, isc_boolean_t lasttoken, static void
const char *fmt, ...); 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
static isc_boolean_t is_ip4addr(const char *string, struct in_addr *addr); is_ip6addr(const char *string, struct in6_addr *addr);
static isc_result_t getnexttoken(ndcpcontext *pctx); static isc_boolean_t
static void syntax_error(ndcpcontext *pctx, isc_uint32_t keyword); 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) { ...@@ -1400,7 +1411,7 @@ parser_setup(ndcpcontext *pctx, isc_mem_t *mem, const char *filename) {
ISC_LEXCOMMENT_CPLUSPLUS | ISC_LEXCOMMENT_CPLUSPLUS |
ISC_LEXCOMMENT_SHELL)); ISC_LEXCOMMENT_SHELL));
result = isc_lex_openfile(pctx->thelexer, (char *)filename); result = isc_lex_openfile(pctx->thelexer, filename);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG, isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG, ISC_LOG_CRITICAL, DNS_LOGMODULE_CONFIG, ISC_LOG_CRITICAL,
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* SOFTWARE. * 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> #include <config.h>
...@@ -126,7 +126,7 @@ static void parser_complain(isc_boolean_t is_warning, ...@@ -126,7 +126,7 @@ static void parser_complain(isc_boolean_t is_warning,
isc_boolean_t last_token, isc_boolean_t last_token,
const char *format, va_list args); const char *format, va_list args);
static isc_boolean_t unit_to_uint32(char *in, isc_uint32_t *out); 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 void yyerror(const char *);
static dns_peerlist_t *currentpeerlist(dns_c_ctx_t *cfg, static dns_peerlist_t *currentpeerlist(dns_c_ctx_t *cfg,
isc_boolean_t createIfNeeded); isc_boolean_t createIfNeeded);
...@@ -2429,7 +2429,7 @@ category_name: any_string ...@@ -2429,7 +2429,7 @@ category_name: any_string
} }
| L_DEFAULT | L_DEFAULT
{ {
char *name = token_to_keyword(L_DEFAULT); const char *name = token_to_keyword(L_DEFAULT);
REQUIRE(name != NULL); REQUIRE(name != NULL);
...@@ -2437,7 +2437,7 @@ category_name: any_string ...@@ -2437,7 +2437,7 @@ category_name: any_string
} }
| L_NOTIFY | L_NOTIFY
{ {
char *name = token_to_keyword(L_NOTIFY); const char *name = token_to_keyword(L_NOTIFY);
REQUIRE(name != NULL); REQUIRE(name != NULL);
...@@ -4881,7 +4881,7 @@ static int lasttoken; ...@@ -4881,7 +4881,7 @@ static int lasttoken;
*/ */
struct token struct token
{ {
char *token; const char *token;
int yaccval; int yaccval;
}; };
...@@ -5160,7 +5160,7 @@ dns_c_parse_namedconf(const char *filename, isc_mem_t *mem, ...@@ -5160,7 +5160,7 @@ dns_c_parse_namedconf(const char *filename, isc_mem_t *mem,
ISC_LEXCOMMENT_CPLUSPLUS | ISC_LEXCOMMENT_CPLUSPLUS |
ISC_LEXCOMMENT_SHELL)); ISC_LEXCOMMENT_SHELL));
res = isc_lex_openfile(mylexer, (char *)filename); /* remove const */ res = isc_lex_openfile(mylexer, filename);
if (res != ISC_R_SUCCESS) { if (res != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG, isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG, ISC_LOG_CRITICAL, DNS_LOGMODULE_CONFIG, ISC_LOG_CRITICAL,
...@@ -5324,9 +5324,11 @@ yylex(void) ...@@ -5324,9 +5324,11 @@ yylex(void)
static char * static char *
token_to_text(int token, YYSTYPE lval) { token_to_text(int token, YYSTYPE lval) {
static char buffer[1024]; 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 < 128) {
if (token == 0) if (token == 0)
strncpy(buffer, "<end of file>", sizeof buffer); strncpy(buffer, "<end of file>", sizeof buffer);
...@@ -5383,9 +5385,8 @@ token_to_text(int token, YYSTYPE lval) { ...@@ -5383,9 +5385,8 @@ token_to_text(int token, YYSTYPE lval) {
return (buffer); return (buffer);
} }
static char * static const char *
token_to_keyword(int token) token_to_keyword(int token) {
{
int i; int i;
for (i = 0 ; keyword_tokens[i].token != NULL ; i++) { for (i = 0 ; keyword_tokens[i].token != NULL ; i++) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* SOFTWARE. * 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> #include <config.h>
...@@ -82,9 +82,9 @@ dns_c_rrsolist_new(isc_mem_t *mem, dns_c_rrsolist_t **rval) { ...@@ -82,9 +82,9 @@ dns_c_rrsolist_new(isc_mem_t *mem, dns_c_rrsolist_t **rval) {
} }
isc_result_t isc_result_t
dns_c_rrso_new(isc_mem_t *mem, dns_c_rrso_t **res, dns_c_rrso_new(isc_mem_t *mem, dns_c_rrso_t **res, dns_rdataclass_t oclass,
dns_rdataclass_t oclass, dns_rdatatype_t otype, const char *name,
dns_rdatatype_t otype, char *name, dns_c_ordering_t ordering) dns_c_ordering_t ordering)
{ {
dns_c_rrso_t *newo; dns_c_rrso_t *newo;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
***/ ***/
typedef struct { typedef struct {
char * name; const char * name;
isc_result_t (*create)(isc_mem_t *mctx, dns_name_t *name, isc_result_t (*create)(isc_mem_t *mctx, dns_name_t *name,
isc_boolean_t cache, isc_boolean_t cache,
dns_rdataclass_t rdclass, dns_rdataclass_t rdclass,
...@@ -67,7 +67,7 @@ static impinfo_t implementations[] = { ...@@ -67,7 +67,7 @@ static impinfo_t implementations[] = {
***/ ***/
isc_result_t 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, isc_boolean_t cache, dns_rdataclass_t rdclass,
unsigned int argc, char *argv[], dns_db_t **dbp) unsigned int argc, char *argv[], dns_db_t **dbp)
{ {
......
...@@ -16,7 +16,7 @@ ...@@ -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 * Principal Author: Brian Wellington
*/ */
...@@ -92,7 +92,8 @@ digest_callback(void *arg, isc_region_t *data) { ...@@ -92,7 +92,8 @@ digest_callback(void *arg, isc_region_t *data) {
*/ */
static int static int
rdata_compare_wrapper(const void *rdata1, const void *rdata2) { 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 @@ ...@@ -15,7 +15,7 @@
* SOFTWARE. * 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> #include <config.h>
...@@ -151,13 +151,21 @@ struct ttnam { ...@@ -151,13 +151,21 @@ struct ttnam {
unsigned int sorted; unsigned int sorted;
} typenames[256]; } typenames[256];
char * upper(char *); char *
char * funname(char *, char *); upper(char *);
void doswitch(char *, char *, char *, char *, char *, char *); char *
void dodecl(char *, char *, char *); funname(char *, char *);
void add(int, char *, int, char *, char *); void
void sd(int, char *, char *, char); doswitch(const char *, const char *, const char *, const char *,
void insert_into_typenames(int, char *, 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. * 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) { ...@@ -195,15 +203,15 @@ funname(char *s, char *buf) {
} }
void void
doswitch(char *name, char *function, char *args, doswitch(const char *name, const char *function, const char *args,
char *tsw, char *csw, char *res) const char *tsw, const char *csw, const char *res)
{ {
struct tt *tt; struct tt *tt;
int first = 1; int first = 1;
int lasttype = 0; int lasttype = 0;
int subswitch = 0; int subswitch = 0;
char buf1[11], buf2[11]; char buf1[11], buf2[11];
char *result = " result ="; const char *result = " result =";
if (res == NULL) if (res == NULL)
result = ""; result = "";
...@@ -286,8 +294,7 @@ dodecl(char *type, char *function, char *args) { ...@@ -286,8 +294,7 @@ dodecl(char *type, char *function, char *args) {
} }
void void
insert_into_typenames(int type, char *typename, char *attr) insert_into_typenames(int type, const char *typename, const char *attr) {
{
struct ttnam *ttn; struct ttnam *ttn;
int c; int c;
char tmp[256]; char tmp[256];
...@@ -335,7 +342,9 @@ insert_into_typenames(int type, char *typename, char *attr) ...@@ -335,7 +342,9 @@ insert_into_typenames(int type, char *typename, char *attr)
} }
void 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 *newtt = (struct tt *)malloc(sizeof *newtt);
struct tt *tt, *oldtt; struct tt *tt, *oldtt;
struct cc *newcc; struct cc *newcc;
...@@ -409,7 +418,7 @@ add(int rdclass, char *classname, int type, char *typename, char *dirname) { ...@@ -409,7 +418,7 @@ add(int rdclass, char *classname, int type, char *typename, char *dirname) {
} }
void 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 buf[sizeof "0123456789_65535.h"];
char fmt[sizeof "%10[-0-9a-z]_%d.h"]; char fmt[sizeof "%10[-0-9a-z]_%d.h"];
int type; int type;
...@@ -436,8 +445,7 @@ sd(int rdclass, char *classname, char *dirname, char filetype) { ...@@ -436,8 +445,7 @@ sd(int rdclass, char *classname, char *dirname, char filetype) {
} }
static unsigned int static unsigned int
HASH(char *string) HASH(char *string) {
{
unsigned int n; unsigned int n;
unsigned char a, b; unsigned char a, b;
...@@ -617,7 +625,7 @@ main(int argc, char **argv) { ...@@ -617,7 +625,7 @@ main(int argc, char **argv) {