]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
write-strings warnings fixed.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 4 Nov 2008 14:53:50 +0000 (14:53 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 4 Nov 2008 14:53:50 +0000 (14:53 +0000)
git-svn-id: file:///svn/unbound/trunk@1330 be551aaa-1e26-0410-a405-d3ace91eadb9

16 files changed:
daemon/remote.c
daemon/unbound.c
doc/Changelog
services/localzone.c
smallapp/unbound-checkconf.c
smallapp/unbound-control.c
smallapp/unbound-host.c
testcode/delayer.c
testcode/harvest.c
testcode/replay.c
testcode/streamtcp.c
testcode/testbound.c
testcode/unitmain.c
util/config_file.c
util/config_file.h
util/module.h

index 94613c5b0ad3346e2127abbc73d59ff9a600c504..d4b7ae7a52ef88f4777d3d9b3f0ce372ab11fb0e 100644 (file)
@@ -219,7 +219,7 @@ void daemon_remote_delete(struct daemon_remote* rc)
  * @return false on failure.
  */
 static int
-add_open(char* ip, int nr, struct listen_port** list, int noproto_is_err)
+add_open(const char* ip, int nr, struct listen_port** list, int noproto_is_err)
 {
        struct addrinfo hints;
        struct addrinfo* res;
@@ -554,7 +554,7 @@ do_verbosity(SSL* ssl, char* str)
 
 /** print stats from statinfo */
 static int
-print_stats(SSL* ssl, char* nm, struct stats_info* s)
+print_stats(SSL* ssl, const char* nm, struct stats_info* s)
 {
        struct timeval avg;
        if(!ssl_printf(ssl, "%s.num.queries"SQ"%u\n", nm, 
index 6325a5eefcf5e1a01480dc6eb2f1d1176aefdb1f..2a53ca0b52bcf9833e2bb764a61f78e8fdbe4a59 100644 (file)
@@ -315,7 +315,7 @@ detach(void)
 /** daemonize, drop user priviliges and chroot if needed */
 static void
 perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
-       char** cfgfile)
+       const char** cfgfile)
 {
 #ifdef HAVE_GETPWNAM
        uid_t uid;
@@ -477,7 +477,7 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
  * @param debug_mode: if set, do not daemonize.
  */
 static void 
-run_daemon(char* cfgfile, int cmdline_verbose, int debug_mode)
+run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode)
 {
        struct config_file* cfg = NULL;
        struct daemon* daemon = NULL;
@@ -546,7 +546,7 @@ int
 main(int argc, char* argv[])
 {
        int c;
-       char* cfgfile = CONFIGFILE;
+       const char* cfgfile = CONFIGFILE;
        int cmdline_verbose = 0;
        int debug_mode = 0;
 
index 2eacdb9d7c60210a1f535bac5a561aad89125931..6466284083481b18a8c78cc3e1f26a51f70261c4 100644 (file)
@@ -1,3 +1,6 @@
+4 November 2008: Wouter
+       - fixed -Wwrite-strings warnings that result in better code.
+
 3 November 2008: Wouter
        - fixup build process for Mac OSX linker, use ldns b32 compat funcs.
        - generated configure with autoconf-2.61.
index a7452ea393219b2696933b34fd631ab8e6374b65..d0c7af8309945b2127139445ade57bc2c90f1c0e 100644 (file)
@@ -580,7 +580,7 @@ lz_nodefault(struct config_file* cfg, const char* name)
 /** enter AS112 default zone */
 static int
 add_as112_default(struct local_zones* zones, struct config_file* cfg,
-        ldns_buffer* buf, char* name)
+        ldns_buffer* buf, const char* name)
 {
        struct local_zone* z;
        char str[1024]; /* known long enough */
index d23f5c04076a0b2a6e25eb7ca9337ab09eb761a0..539710270edb0eded3c4199ce0a91ce8a1b3d4e7 100644 (file)
@@ -260,7 +260,7 @@ check_chroot_filelist(const char* desc, struct config_strlist* list,
 
 /** check configuration for errors */
 static void
-morechecks(struct config_file* cfg, char* fname)
+morechecks(struct config_file* cfg, const char* fname)
 {
        warn_hosts("stub-host", cfg->stubs);
        warn_hosts("forward-host", cfg->forwards);
@@ -353,7 +353,7 @@ morechecks(struct config_file* cfg, char* fname)
 
 /** check config file */
 static void
-checkconf(char* cfgfile)
+checkconf(const char* cfgfile)
 {
        struct config_file* cfg = config_create();
        if(!cfg)
@@ -379,7 +379,7 @@ extern char* optarg;
 int main(int argc, char* argv[])
 {
        int c;
-       char* f;
+       const char* f;
        log_ident_set("unbound-checkconf");
        log_init(NULL, 0, NULL);
        checklock_start();
index 2329568690d2b4bbab868c69457474a6d20ea7ce..728667e3f5a38746cd29dd76885c1618b78355d5 100644 (file)
@@ -124,7 +124,7 @@ setup_ctx(struct config_file* cfg)
 
 /** contact the server with TCP connect */
 static int
-contact_server(char* svr, struct config_file* cfg)
+contact_server(const char* svr, struct config_file* cfg)
 {
        struct sockaddr_storage addr;
        socklen_t addrlen;
@@ -220,9 +220,9 @@ send_file(SSL* ssl, FILE* in, char* buf, size_t sz)
 static int
 go_cmd(SSL* ssl, int argc, char* argv[])
 {
-       char* pre="UBCT";
-       char* space=" ";
-       char* newline="\n";
+       const char* pre="UBCT";
+       const char* space=" ";
+       const char* newline="\n";
        int was_error = 0, first_line = 1;
        int r, i;
        char buf[1024];
@@ -261,7 +261,7 @@ go_cmd(SSL* ssl, int argc, char* argv[])
 
 /** go ahead and read config, contact server and perform command and display */
 static int
-go(char* cfgfile, char* svr, int argc, char* argv[])
+go(const char* cfgfile, char* svr, int argc, char* argv[])
 {
        struct config_file* cfg;
        int fd, ret;
@@ -300,7 +300,7 @@ extern char* optarg;
 int main(int argc, char* argv[])
 {
        int c, ret;
-       char* cfgfile = CONFIGFILE;
+       const char* cfgfile = CONFIGFILE;
        char* svr = NULL;
 #ifdef USE_WINSOCK
        int r;
index f7949906ae4de627630801122d1f817c602c8837..43b05432d190601dcd632c131ae39a24fdef0d98 100644 (file)
@@ -99,7 +99,7 @@ isip6(const char* nm, char** res)
 {
        struct in6_addr addr;
        /* [nibble.]{32}.ip6.arpa. is less than 128 */
-       char* hex = "0123456789abcdef";
+       const char* hex = "0123456789abcdef";
        char buf[128];
        char *p;
        int i;
index 4bf8d98e73665e55bb228471c7147be366e26b00..9ed7ca2e5c45f394decb0582038762ed7650bad2 100644 (file)
@@ -966,8 +966,8 @@ service_loop(int udp_s, int listen_s, struct ringbuf* ring,
 
 /** delayer main service routine */
 static void
-service(char* bind_str, int bindport, char* serv_str, size_t memsize
-       int delay_msec)
+service(const char* bind_str, int bindport, const char* serv_str
+       size_t memsize, int delay_msec)
 {
        struct sockaddr_storage bind_addr, srv_addr;
        socklen_t bind_len, srv_len;
@@ -1098,8 +1098,8 @@ extern char* optarg;
 int main(int argc, char** argv) 
 {
        int c;          /* defaults */
-       char* server = "127.0.0.1@53";
-       char* bindto = "0.0.0.0";
+       const char* server = "127.0.0.1@53";
+       const char* bindto = "0.0.0.0";
        int bindport = 0;
        size_t memsize = 10*1024*1024;
        int delay = 100;
index 08ce08d33a6780fc2da4c29a23e992eb6f5f8a5a..f0b6f90c403856710e9c64dce168af0684034929 100644 (file)
@@ -168,7 +168,7 @@ static void usage(char* nm)
 static int hverb = 0;
 
 /** exit with error */
-static void error_exit(char* str)
+static void error_exit(const char* str)
 {
        printf("error: %s\n", str);
        exit(1);
@@ -235,7 +235,7 @@ lab_cmp(const void *x, const void *y)
 
 /** create label entry */
 static struct labdata*
-lab_create(char* name)
+lab_create(const char* name)
 {
        struct labdata* lab = (struct labdata*)calloc(1, sizeof(*lab));
        if(!lab) error_exit("out of memory");
index 8e3e036534f423030065ca0f6feecee09f92f429..22b8908b39ee56206dba117b95cc1cd09a8888ad 100644 (file)
@@ -54,7 +54,7 @@
  * @return: true if found, false if not. 
  */
 static int 
-parse_keyword(char** line, char* keyword)
+parse_keyword(char** line, const char* keyword)
 {
        size_t len = (size_t)strlen(keyword);
        if(strncmp(*line, keyword, len) == 0) {
index ebfec90074e71e707d7697ac551b4b62a8331e15..aaa5892c5b00b26f78993e9fd7833069d80a3040 100644 (file)
@@ -62,7 +62,7 @@ void usage(char* argv[])
 
 /** open TCP socket to svr */
 static int
-open_svr(char* svr, int udp)
+open_svr(const char* svr, int udp)
 {
        struct sockaddr_storage addr;
        socklen_t addrlen;
@@ -96,7 +96,7 @@ open_svr(char* svr, int udp)
 /** write a query over the TCP fd */
 static void
 write_q(int fd, int udp, ldns_buffer* buf, int id, 
-       char* strname, char* strtype, char* strclass)
+       const char* strname, const char* strtype, const char* strclass)
 {
        struct query_info qinfo;
        ldns_rdf* rdf;
@@ -210,7 +210,7 @@ recv_one(int fd, int udp, ldns_buffer* buf)
 
 /** send the TCP queries and print answers */
 static void
-send_em(char* svr, int udp, int noanswer, int num, char** qs)
+send_em(const char* svr, int udp, int noanswer, int num, char** qs)
 {
        ldns_buffer* buf = ldns_buffer_new(65553);
        int fd = open_svr(svr, udp);
@@ -251,7 +251,7 @@ extern char* optarg;
 int main(int argc, char** argv) 
 {
        int c;
-       char* svr = "127.0.0.1";
+       const char* svr = "127.0.0.1";
        int udp = 0;
        int noanswer = 0;
 
index d3b75e8493d4e980dd68bc5344c4ea527d53979f..a83ea0f13649dba5ed22ff552e188de18690d2de 100644 (file)
@@ -82,9 +82,9 @@ testbound_usage()
  * @param pass_argv: the argv to pass to unbound. Modified.
  */
 static void
-add_opts(char* optarg, int* pass_argc, char* pass_argv[])
+add_opts(const char* optarg, int* pass_argc, char* pass_argv[])
 {
-       char *p = optarg, *np;
+       const char *p = optarg, *np;
        size_t len;
        while(p && isspace((int)*p)) 
                p++;
index 66fc5c73c862693ff9c39adf5139e3b75053994b..7837e38360225d08c7ff224cfca4c8d7472e1748 100644 (file)
@@ -89,7 +89,7 @@ alloc_test() {
 static void 
 net_test()
 {
-       char* t4[] = {"\000\000\000\000",
+       const char* t4[] = {"\000\000\000\000",
                "\200\000\000\000",
                "\300\000\000\000",
                "\340\000\000\000",
index 5d91f5d9d0d6a077056c9670c9999d41678c2377..5fcc35c01cd25fb3fd73e5a3022f5709d50f6197 100644 (file)
@@ -423,7 +423,7 @@ create_cfg_parser(struct config_file* cfg, char* filename)
 }
 
 int 
-config_read(struct config_file* cfg, char* filename)
+config_read(struct config_file* cfg, const char* filename)
 {
        FILE *in;
        if(!filename)
@@ -433,7 +433,7 @@ config_read(struct config_file* cfg, char* filename)
                log_err("Could not open %s: %s", filename, strerror(errno));
                return 0;
        }
-       create_cfg_parser(cfg, filename);
+       create_cfg_parser(cfg, (char*)filename);
        ub_c_in = in;
        ub_c_parse();
        fclose(in);
@@ -965,7 +965,7 @@ char* cfg_ptr_reverse(char* str)
 
        if(addr_is_ip6(&addr, addrlen)) {
                struct in6_addr* ad = &((struct sockaddr_in6*)&addr)->sin6_addr;
-               char* hex = "0123456789abcdef";
+               const char* hex = "0123456789abcdef";
                char *p = buf;
                int i;
                for(i=15; i>=0; i--) {
index c26a5f74e08bbc89c4c794c37b570c91c8f16aba..363a24ea9304075a3489a27c973c6f9c12a20e78 100644 (file)
@@ -298,7 +298,7 @@ struct config_file* config_create_forlib();
  * @return: false on error. In that case errno is set, ENOENT means 
  *     file not found.
  */
-int config_read(struct config_file* config, char* filename);
+int config_read(struct config_file* config, const char* filename);
 
 /**
  * Destroy the config file structure.
index 68308835bcdd28a37a101f829f4969a2d4a747eb..21682849043f465417091411a1b8620c3b6baef3 100644 (file)
@@ -289,7 +289,7 @@ struct module_qstate {
  */
 struct module_func_block {
        /** text string name of module */
-       char* name;
+       const char* name;
 
        /** 
         * init the module. Called once for the global state.