]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace DE_CONST(k, v) with v = UNCONST(k) macro
authorOndřej Surý <ondrej@isc.org>
Thu, 30 Mar 2023 20:34:12 +0000 (22:34 +0200)
committerOndřej Surý <ondrej@isc.org>
Mon, 3 Apr 2023 10:25:56 +0000 (10:25 +0000)
Replace the complicated DE_CONST macro that required union with much
simple reference-dereference trick in the UNCONST() macro.

28 files changed:
bin/check/check-tool.c
bin/check/named-checkconf.c
bin/dnssec/dnssec-signzone.c
bin/dnssec/dnssectool.c
bin/named/builtin.c
bin/named/config.c
bin/named/server.c
bin/named/statschannel.c
bin/named/zoneconf.c
contrib/dlz/modules/include/dlz_minimal.h
contrib/dlz/modules/wildcard/dlz_wildcard_dynamic.c
lib/dns/dnstap.c
lib/dns/rdata/generic/txt_16.c
lib/dns/tsig.c
lib/dns/view.c
lib/dns/zone.c
lib/dns/zoneverify.c
lib/isc/include/isc/util.h
lib/isc/log.c
lib/isc/netaddr.c
lib/isc/symtab.c
lib/isc/tm.c
lib/isccc/cc.c
lib/isccfg/aclconf.c
lib/isccfg/check.c
lib/isccfg/kaspconf.c
tests/dns/keytable_test.c
tests/dns/nsec3param_test.c

index 6087f1124936af5cd5d4fcf6711432e76def9765..77aecccc70edf29e5b5a717f3a963f25ea0da039 100644 (file)
@@ -616,7 +616,7 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
                CHECK(dns_zone_setjournal(zone, journal));
        }
 
-       DE_CONST(classname, region.base);
+       region.base = UNCONST(classname);
        region.length = strlen(classname);
        CHECK(dns_rdataclass_fromtext(&rdclass, &region));
 
index 4a25acb2def2639ec93252daa2ef8fc88c389ba3..19f672224e4808cc1926c9bd3c31be02162bfa66 100644 (file)
@@ -155,7 +155,7 @@ configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
                return (ISC_R_FAILURE);
        }
 
-       DE_CONST(zclass, r.base);
+       r.base = UNCONST(zclass);
        r.length = strlen(zclass);
        result = dns_rdataclass_fromtext(&rdclass, &r);
        if (result != ISC_R_SUCCESS) {
@@ -510,7 +510,7 @@ config_getclass(const cfg_obj_t *classobj, dns_rdataclass_t defclass,
                *classp = defclass;
                return (ISC_R_SUCCESS);
        }
-       DE_CONST(cfg_obj_asstring(classobj), r.base);
+       r.base = UNCONST(cfg_obj_asstring(classobj));
        r.length = strlen(r.base);
        return (dns_rdataclass_fromtext(classp, &r));
 }
index 82cb3d00d11d41dca093575acde1084dd125531c..c038ab325258fd615948c61525bba4d6df878893 100644 (file)
@@ -1962,7 +1962,7 @@ addnsec3param(const unsigned char *salt, size_t salt_len,
        nsec3param.hash = unknownalg ? DNS_NSEC3_UNKNOWNALG : dns_hash_sha1;
        nsec3param.iterations = iterations;
        nsec3param.salt_length = (unsigned char)salt_len;
-       DE_CONST(salt, nsec3param.salt);
+       nsec3param.salt = UNCONST(salt);
 
        isc_buffer_init(&b, nsec3parambuf, sizeof(nsec3parambuf));
        result = dns_rdata_fromstruct(&rdata, gclass, dns_rdatatype_nsec3param,
@@ -2811,7 +2811,7 @@ build_final_keylist(void) {
                char *s;
                size_t dlen;
 
-               DE_CONST(sync_records, digest);
+               digest = UNCONST(sync_records);
        next_digest:
                s = strchr(digest, delim);
                if (s == NULL) {
index 62c74765591205ba11f4890d9b621b5faa247341..0bf8cc78269b3f12bd27f62af216e18ed1ead821 100644 (file)
@@ -376,7 +376,7 @@ strtoclass(const char *str) {
        if (str == NULL) {
                return (dns_rdataclass_in);
        }
-       DE_CONST(str, r.base);
+       r.base = UNCONST(str);
        r.length = strlen(str);
        result = dns_rdataclass_fromtext(&rdclass, &r);
        if (result != ISC_R_SUCCESS) {
@@ -391,7 +391,7 @@ strtodsdigest(const char *str) {
        dns_dsdigest_t alg;
        isc_result_t result;
 
-       DE_CONST(str, r.base);
+       r.base = UNCONST(str);
        r.length = strlen(str);
        result = dns_dsdigest_fromtext(&alg, &r);
        if (result != ISC_R_SUCCESS) {
index b0767a1e52fe7b13cb35aec1ca3d309cec0c19ca..f2e6f2ed75538ea2ac94783d02c5986e6ae60821 100644 (file)
@@ -126,7 +126,7 @@ putrdata(bdbnode_t *node, dns_rdatatype_t typeval, dns_ttl_t ttl,
        rdata = isc_mem_get(mctx, sizeof(dns_rdata_t));
 
        isc_buffer_allocate(mctx, &rdatabuf, rdlen);
-       DE_CONST(rdatap, region.base);
+       region.base = UNCONST(rdatap);
        region.length = rdlen;
        isc_buffer_copyregion(rdatabuf, &region);
        isc_buffer_usedregion(rdatabuf, &region);
index b470486df466173d061e18dea0fb8f04d5c0a6f5..2149b29b85946ad65a6253dadbf09a057ba60fca 100644 (file)
@@ -441,7 +441,7 @@ named_config_getclass(const cfg_obj_t *classobj, dns_rdataclass_t defclass,
                *classp = defclass;
                return (ISC_R_SUCCESS);
        }
-       DE_CONST(cfg_obj_asstring(classobj), r.base);
+       r.base = UNCONST(cfg_obj_asstring(classobj));
        r.length = strlen(r.base);
        result = dns_rdataclass_fromtext(classp, &r);
        if (result != ISC_R_SUCCESS) {
@@ -461,7 +461,7 @@ named_config_gettype(const cfg_obj_t *typeobj, dns_rdatatype_t deftype,
                *typep = deftype;
                return (ISC_R_SUCCESS);
        }
-       DE_CONST(cfg_obj_asstring(typeobj), r.base);
+       r.base = UNCONST(cfg_obj_asstring(typeobj));
        r.length = strlen(r.base);
        result = dns_rdatatype_fromtext(typep, &r);
        if (result != ISC_R_SUCCESS) {
index 47174867a7155c87caa2dae4841f86470edd85b4..593163ffe50e939cfcf9757d53f6e5ac12081342 100644 (file)
@@ -1674,7 +1674,7 @@ disable_algorithms(const cfg_obj_t *disabled, dns_resolver_t *resolver) {
                isc_textregion_t r;
                dns_secalg_t alg;
 
-               DE_CONST(cfg_obj_asstring(cfg_listelt_value(element)), r.base);
+               r.base = UNCONST(cfg_obj_asstring(cfg_listelt_value(element)));
                r.length = strlen(r.base);
 
                result = dns_secalg_fromtext(&alg, &r);
@@ -1717,7 +1717,7 @@ disable_ds_digests(const cfg_obj_t *disabled, dns_resolver_t *resolver) {
                isc_textregion_t r;
                dns_dsdigest_t digest;
 
-               DE_CONST(cfg_obj_asstring(cfg_listelt_value(element)), r.base);
+               r.base = UNCONST(cfg_obj_asstring(cfg_listelt_value(element)));
                r.length = strlen(r.base);
 
                /* disable_ds_digests handles numeric values. */
@@ -8488,8 +8488,7 @@ load_configuration(const char *filename, named_server_t *server,
        result = named_config_get(maps, "geoip-directory", &obj);
        INSIST(result == ISC_R_SUCCESS);
        if (cfg_obj_isstring(obj)) {
-               char *dir;
-               DE_CONST(cfg_obj_asstring(obj), dir);
+               char *dir = UNCONST(cfg_obj_asstring(obj));
                named_geoip_load(dir);
        }
        named_g_aclconfctx->geoip = named_g_geoip;
@@ -12683,7 +12682,7 @@ nzf_writeconf(const cfg_obj_t *config, dns_view_t *view) {
                CHECK(ISC_R_FAILURE);
        }
 
-       DE_CONST(&zl->value.list, list);
+       list = UNCONST(&zl->value.list);
 
        CHECK(add_comment(fp, view->name)); /* force a comment */
 
@@ -13371,7 +13370,7 @@ delete_zoneconf(dns_view_t *view, cfg_parser_t *pctx, const cfg_obj_t *config,
                CHECK(ISC_R_FAILURE);
        }
 
-       DE_CONST(&zl->value.list, list);
+       list = UNCONST(&zl->value.list);
 
        myname = dns_fixedname_initname(&myfixed);
 
@@ -13388,7 +13387,7 @@ delete_zoneconf(dns_view_t *view, cfg_parser_t *pctx, const cfg_obj_t *config,
                        continue;
                }
 
-               DE_CONST(elt, e);
+               e = UNCONST(elt);
                ISC_LIST_UNLINK(*list, e, link);
                cfg_obj_destroy(pctx, &e->obj);
                isc_mem_put(pctx->mctx, e, sizeof(*e));
@@ -13517,8 +13516,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
        if (cfg->nzf_config == NULL) {
                cfg_obj_attach(zoneconf, &cfg->nzf_config);
        } else {
-               cfg_obj_t *z;
-               DE_CONST(zoneobj, z);
+               cfg_obj_t *z = UNCONST(zoneobj);
                CHECK(cfg_parser_mapadd(cfg->add_parser, cfg->nzf_config, z,
                                        "zone"));
        }
@@ -13761,7 +13759,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
 
 #ifndef HAVE_LMDB
        /* Store the new zone configuration; also in NZF if applicable */
-       DE_CONST(zoneobj, z);
+       z = UNCONST(zoneobj);
        CHECK(cfg_parser_mapadd(cfg->add_parser, cfg->nzf_config, z, "zone"));
 #endif /* HAVE_LMDB */
 
index 45b00d5710739477c487312c8719cb0062febf33..7c924b1f86fac223dfd3753e3b07c28a8caba6d8 100644 (file)
@@ -3300,7 +3300,7 @@ render_json(uint32_t flags, void *arg, unsigned int *retcode,
                *retcode = 200;
                *retmsg = "OK";
                *mimetype = "application/json";
-               DE_CONST(msg, p);
+               p = UNCONST(msg);
                isc_buffer_reinit(b, p, msglen);
                isc_buffer_add(b, msglen);
                *freecb = wrap_jsonfree;
@@ -3442,7 +3442,7 @@ render_xsl(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, void *args,
 send:
        *retcode = 200;
        *retmsg = "OK";
-       DE_CONST(xslmsg, p);
+       p = UNCONST(xslmsg);
        isc_buffer_reinit(b, p, strlen(xslmsg));
        isc_buffer_add(b, strlen(xslmsg));
 end:
index f7184f4c86521a96e360d5f9f19e1349f00d938b..9e392eb25aab518d7844966602ebb87632bfeb81 100644 (file)
@@ -305,7 +305,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
 
                        typeobj = cfg_listelt_value(element2);
                        str = cfg_obj_asstring(typeobj);
-                       DE_CONST(str, r.base);
+                       r.base = UNCONST(str);
 
                        bracket = strchr(str, '(' /*)*/);
                        if (bracket != NULL) {
index 32f0f12f93601c2bec3a547ce92214e84dae77d4..f2a69e40b89671dba5686363775e4728f26d3b3c 100644 (file)
@@ -75,15 +75,8 @@ typedef uint32_t     dns_ttl_t;
 
 /* other useful definitions */
 #define UNUSED(x) (void)(x)
-#define DE_CONST(konst, var)           \
-       do {                           \
-               union {                \
-                       const void *k; \
-                       void       *v; \
-               } _u;                  \
-               _u.k = konst;          \
-               var = _u.v;            \
-       } while (0)
+
+#define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
 
 #if !defined(__has_c_attribute)
 #define __has_c_attribute(x) 0
index 95221a1e5ef83f2d7fa2e2d1ed0ba7526108f1a8..2bb69759913e1c193e97aacebb44621c92db301b 100644 (file)
 #include <dlz_list.h>
 #include <dlz_minimal.h>
 
-#define DE_CONST(konst, var)           \
-       do {                           \
-               union {                \
-                       const void *k; \
-                       void *v;       \
-               } _u;                  \
-               _u.k = konst;          \
-               var = _u.v;            \
-       } while (0)
-
 /* fnmatch() return values. */
 #define FNM_NOMATCH 1 /* Match failed. */
 
@@ -119,7 +109,7 @@ dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes) {
        nrr_t *nrec;
        int i = 0;
 
-       DE_CONST(zone, cd->zone);
+       cd->zone = UNCONST(zone);
 
        /* Write info message to log */
        cd->log(ISC_LOG_DEBUG(1), "dlz_wildcard allnodes called for zone '%s'",
@@ -235,8 +225,8 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
                return (ISC_R_NOTFOUND);
        }
 
-       DE_CONST(name, cd->record);
-       DE_CONST(p, cd->zone);
+       cd->record = UNCONST(name);
+       cd->zone = UNCONST(p);
 
        if ((p != zone) && (strcmp(name, "@") == 0 || strcmp(name, zone) == 0))
        {
@@ -315,7 +305,7 @@ dlz_authority(const char *zone, void *dbdata, dns_sdlzlookup_t *lookup) {
                return (ISC_R_NOTFOUND);
        }
 
-       DE_CONST(p, cd->zone);
+       cd->zone = UNCONST(p);
 
        /* Write info message to log */
        cd->log(ISC_LOG_DEBUG(1), "dlz_wildcard_dynamic: authority for '%s'",
index bb616ea08be0ab119f14137f9e0fd6c24f00a0b5..e2fcc9ef97ee9f596b0043817751304bf0a85307 100644 (file)
@@ -997,7 +997,7 @@ dns_dt_getframe(dns_dthandle_t *handle, uint8_t **bufp, size_t *sizep) {
                if (data == NULL) {
                        return (ISC_R_FAILURE);
                }
-               DE_CONST(data, *bufp);
+               *bufp = UNCONST(data);
                return (ISC_R_SUCCESS);
        case fstrm_res_stop:
                return (ISC_R_NOMORE);
index 3acd66abdd4e9423398f9308bb8740f357e30c27..ce202496860e10af013cc1cfc8d873ec35756472 100644 (file)
@@ -30,7 +30,7 @@ generic_fromtext_txt(ARGS_FROMTEXT) {
        strings = 0;
        if ((options & DNS_RDATA_UNKNOWNESCAPE) != 0) {
                isc_textregion_t r;
-               DE_CONST("#", r.base);
+               r.base = UNCONST("#");
                r.length = 1;
                RETERR(txt_fromtext(&r, target));
                strings++;
index f4278de865f3663c581bf6d993bd1ba59df35034..888c1a4fb19239bdab60412b2c73a1d0c423b955 100644 (file)
@@ -365,8 +365,7 @@ cleanup_refs:
                isc_mem_put(mctx, tkey->creator, sizeof(dns_name_t));
        }
        if (dns__tsig_algallocated(tkey->algorithm)) {
-               dns_name_t *tmpname;
-               DE_CONST(tkey->algorithm, tmpname);
+               dns_name_t *tmpname = UNCONST(tkey->algorithm);
                if (dns_name_dynamic(tmpname)) {
                        dns_name_free(tmpname, mctx);
                }
@@ -719,8 +718,7 @@ tsigkey_free(dns_tsigkey_t *key) {
        key->magic = 0;
        dns_name_free(&key->name, key->mctx);
        if (dns__tsig_algallocated(key->algorithm)) {
-               dns_name_t *name;
-               DE_CONST(key->algorithm, name);
+               dns_name_t *name = UNCONST(key->algorithm);
                dns_name_free(name, key->mctx);
                isc_mem_put(key->mctx, name, sizeof(dns_name_t));
        }
index fdfc295239fd2b6b5ca08e59500be057abfa0bf6..9c3995c6ac978596e32a2b36c4ff4217c09d7d26 100644 (file)
@@ -2328,7 +2328,7 @@ isc_result_t
 dns_view_addtrustedkey(dns_view_t *view, dns_rdatatype_t rdtype,
                       const dns_name_t *keyname, isc_buffer_t *databuf) {
        isc_result_t result;
-       dns_name_t *name = NULL;
+       dns_name_t *name = UNCONST(keyname);
        char rdatabuf[DST_KEY_MAXSIZE];
        unsigned char digest[ISC_MAX_MD_SIZE];
        dns_rdata_ds_t ds;
@@ -2338,8 +2338,6 @@ dns_view_addtrustedkey(dns_view_t *view, dns_rdatatype_t rdtype,
        REQUIRE(DNS_VIEW_VALID(view));
        REQUIRE(view->rdclass == dns_rdataclass_in);
 
-       DE_CONST(keyname, name);
-
        if (rdtype != dns_rdatatype_dnskey && rdtype != dns_rdatatype_ds) {
                result = ISC_R_NOTIMPLEMENTED;
                goto cleanup;
index 450af4b6793639293b269bdbc904aab647e03e68..3fd2783009fbc5be6ef6fd71fcdedc9533775ce0 100644 (file)
@@ -2595,8 +2595,7 @@ zone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) {
 
                return (DNS_R_CONTINUE);
        } else if (zone->stream != NULL) {
-               FILE *stream = NULL;
-               DE_CONST(zone->stream, stream);
+               FILE *stream = UNCONST(zone->stream);
                result = dns_master_loadstream(
                        stream, &zone->origin, &zone->origin, zone->rdclass,
                        options, &load->callbacks, zone->mctx);
@@ -21567,7 +21566,7 @@ dns_zone_keydone(dns_zone_t *zone, const char *keystr) {
 
                n = sscanf(algstr, "%hhu", &alg);
                if (n == 0U) {
-                       DE_CONST(algstr, r.base);
+                       r.base = UNCONST(algstr);
                        r.length = strlen(algstr);
                        CHECK(dns_secalg_fromtext(&alg, &r));
                }
@@ -22011,7 +22010,7 @@ setparam:
        }
 
        if (param->salt_length == 0) {
-               DE_CONST("-", param->salt);
+               param->salt = (unsigned char *)"-";
        } else if (resalt || param->salt == NULL) {
                unsigned char *newsalt;
                unsigned char salttext[255 * 2 + 1];
index bf2b7cc68ea9f418ea457a96a98f064b2390eb74..7709ed8d8aeb46934a489bcfb046337e4f18f92c 100644 (file)
@@ -1079,21 +1079,21 @@ _checknext(const vctx_t *vctx, const struct nsec3_chain_fixed *first,
                return (true);
        }
 
-       DE_CONST(d1 - first->next_length, sr.base);
+       sr.base = UNCONST(d1 - first->next_length);
        sr.length = first->next_length;
        isc_buffer_init(&b, buf, sizeof(buf));
        isc_base32hex_totext(&sr, 1, "", &b);
        zoneverify_log_error(vctx, "Break in NSEC3 chain at: %.*s",
                             (int)isc_buffer_usedlength(&b), buf);
 
-       DE_CONST(d1, sr.base);
+       sr.base = UNCONST(d1);
        sr.length = first->next_length;
        isc_buffer_init(&b, buf, sizeof(buf));
        isc_base32hex_totext(&sr, 1, "", &b);
        zoneverify_log_error(vctx, "Expected: %.*s",
                             (int)isc_buffer_usedlength(&b), buf);
 
-       DE_CONST(d2, sr.base);
+       sr.base = UNCONST(d2);
        sr.length = first->next_length;
        isc_buffer_init(&b, buf, sizeof(buf));
        isc_base32hex_totext(&sr, 1, "", &b);
index ba74a678e7fa430739912ee121b7b2f48b8493a9..eb99583e2096f37b204fbeef3337721d0f2c11ad 100644 (file)
 #define ISC_CLAMP(v, x, y) ((v) < (x) ? (x) : ((v) > (y) ? (y) : (v)))
 
 /*%
- * Use this to remove the const qualifier of a variable to assign it to
- * a non-const variable or pass it as a non-const function argument ...
- * but only when you are sure it won't then be changed!
- * This is necessary to sometimes shut up some compilers
- * (as with gcc -Wcast-qual) when there is just no other good way to avoid the
- * situation.
+ * The UNCONST() macro can be used to omit warnings produced by certain
+ * compilers when operating with pointers declared with the const type qual-
+ * ifier in a context without such qualifier.  Examples include passing a
+ * pointer declared with the const qualifier to a function without such
+ * qualifier, and variable assignment from a const pointer to a non-const
+ * pointer.
+ *
+ * As the macro may hide valid errors, their usage is not recommended
+ * unless there is a well-thought reason for a cast.  A typical use case for
+ * __UNCONST() involve an API that does not follow the so-called ``const
+ * correctness'' even if it would be appropriate.
  */
-#define DE_CONST(konst, var)           \
-       do {                           \
-               union {                \
-                       const void *k; \
-                       void       *v; \
-               } _u;                  \
-               _u.k = konst;          \
-               var = _u.v;            \
-       } while (0)
+#define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 
index dacdafaf8fdd7b8f6886aa8519f146aa97093eb1..a24e1c37fefedbb52a191e7209f5457be9d6cd60 100644 (file)
@@ -456,7 +456,7 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp) {
                         * but in isc_log_createchannel it gets copied
                         * into writable memory and is not longer truly const.
                         */
-                       DE_CONST(FILE_NAME(channel), filename);
+                       filename = UNCONST(FILE_NAME(channel));
                        isc_mem_free(mctx, filename);
 
                        if (FILE_STREAM(channel) != NULL) {
@@ -522,7 +522,7 @@ isc_log_registercategories(isc_log_t *lctx, isc_logcategory_t categories[]) {
                                 * The name pointer points to the next array.
                                 * Ick.
                                 */
-                               DE_CONST(catp->name, catp);
+                               catp = UNCONST(catp->name);
                        } else {
                                catp++;
                        }
@@ -553,7 +553,7 @@ isc_log_categorybyname(isc_log_t *lctx, const char *name) {
                         * catp is neither modified nor returned to the
                         * caller, so removing its const qualifier is ok.
                         */
-                       DE_CONST(catp->name, catp);
+                       catp = UNCONST(catp->name);
                } else {
                        if (strcmp(catp->name, name) == 0) {
                                return (catp);
@@ -593,7 +593,7 @@ isc_log_registermodules(isc_log_t *lctx, isc_logmodule_t modules[]) {
                                 * The name pointer points to the next array.
                                 * Ick.
                                 */
-                               DE_CONST(modp->name, modp);
+                               modp = UNCONST(modp->name);
                        } else {
                                modp++;
                        }
@@ -624,7 +624,7 @@ isc_log_modulebyname(isc_log_t *lctx, const char *name) {
                         * modp is neither modified nor returned to the
                         * caller, so removing its const qualifier is ok.
                         */
-                       DE_CONST(modp->name, modp);
+                       modp = UNCONST(modp->name);
                } else {
                        if (strcmp(modp->name, name) == 0) {
                                return (modp);
@@ -1020,7 +1020,7 @@ greatest_version(isc_logfile_t *file, int versions, int *greatestp) {
        char sep = '/';
 
        /*
-        * It is safe to DE_CONST the file.name because it was copied
+        * It is safe to UNCONST the file.name because it was copied
         * with isc_mem_strdup().
         */
        bname = strrchr(file->name, sep);
@@ -1028,7 +1028,7 @@ greatest_version(isc_logfile_t *file, int versions, int *greatestp) {
                *bname++ = '\0';
                dirname = file->name;
        } else {
-               DE_CONST(file->name, bname);
+               bname = UNCONST(file->name);
                dirname = ".";
        }
        bnamelen = strlen(bname);
@@ -1152,7 +1152,7 @@ remove_old_tsversions(isc_logfile_t *file, int versions) {
        char sep = '/';
 
        /*
-        * It is safe to DE_CONST the file.name because it was copied
+        * It is safe to UNCONST the file.name because it was copied
         * with isc_mem_strdup().
         */
        bname = strrchr(file->name, sep);
@@ -1160,7 +1160,7 @@ remove_old_tsversions(isc_logfile_t *file, int versions) {
                *bname++ = '\0';
                dirname = file->name;
        } else {
-               DE_CONST(file->name, bname);
+               bname = UNCONST(file->name);
                dirname = ".";
        }
        bnamelen = strlen(bname);
index 527546eb208826479820694df57e893f80d26f60..29d5e6834b6c7fbccf26d3c7e94de4a72f256116 100644 (file)
@@ -439,9 +439,8 @@ isc_netaddr_isnetzero(const isc_netaddr_t *na) {
 
 void
 isc_netaddr_fromv4mapped(isc_netaddr_t *t, const isc_netaddr_t *s) {
-       isc_netaddr_t *src;
-
-       DE_CONST(s, src); /* Must come before IN6_IS_ADDR_V4MAPPED. */
+       isc_netaddr_t *src = UNCONST(s); /* Must come before
+                                           IN6_IS_ADDR_V4MAPPED. */
 
        REQUIRE(s->family == AF_INET6);
        REQUIRE(IN6_IS_ADDR_V4MAPPED(&src->type.in6));
index fd507ab9188e2a40b111286f806e699470b9f86d..c4cbcabbbe61b298e828bc5a92c34038ba791384 100644 (file)
@@ -243,7 +243,7 @@ isc_symtab_define(isc_symtab_t *symtab, const char *key, unsigned int type,
         * truly const coming in and then the caller modified it anyway ...
         * well, don't do that!
         */
-       DE_CONST(key, elt->key);
+       elt->key = UNCONST(key);
        elt->type = type;
        elt->value = value;
 
index 65694a0a623b15c5b04e44cba1b1534d17ed276c..eafa11879068e50bd8c7e815a26ca215ccd9b70f 100644 (file)
@@ -135,7 +135,7 @@ isc_tm_timegm(struct tm *tm) {
 
 char *
 isc_tm_strptime(const char *buf, const char *fmt, struct tm *tm) {
-       char c, *ret;
+       char c;
        const char *bp;
        size_t len = 0;
        int alt_format, i, split_year = 0;
@@ -463,6 +463,5 @@ isc_tm_strptime(const char *buf, const char *fmt, struct tm *tm) {
        }
 
        /* LINTED functional specification */
-       DE_CONST(bp, ret);
-       return (ret);
+       return (UNCONST(bp));
 }
index 4fec7f567b09a1ceaf9b063e8321740af7658413..58fb86e6e2c53ae6bf128f03ca5b538827b84f51 100644 (file)
@@ -855,7 +855,7 @@ isccc_cc_definestring(isccc_sexpr_t *alist, const char *key, const char *str) {
        isccc_region_t r;
 
        len = strlen(str);
-       DE_CONST(str, r.rstart);
+       r.rstart = UNCONST(str);
        r.rend = r.rstart + len;
 
        return (isccc_alist_definebinary(alist, key, &r));
index 3f2c6994ee0a5a01aee3f59d9fcfaa3a09ff3824..77154b14df7d57eea2f0d59a4bbd41e5b1f5a9d2 100644 (file)
@@ -152,7 +152,7 @@ convert_named_acl(const cfg_obj_t *nameobj, const cfg_obj_t *cctx,
         */
        memset(&loop, 0, sizeof(loop));
        ISC_LINK_INIT(&loop, nextincache);
-       DE_CONST(aclname, loop.name);
+       loop.name = UNCONST(aclname);
        loop.magic = LOOP_MAGIC;
        ISC_LIST_APPEND(ctx->named_acl_cache, &loop, nextincache);
        result = cfg_acl_fromconfig(cacl, cctx, lctx, ctx, mctx, nest_level,
index dc7936e8db032d852863d04ea01189772b017f26..b0553779130f9506a27a17f28d82913160abb2b9 100644 (file)
@@ -104,7 +104,7 @@ check_orderent(const cfg_obj_t *ent, isc_log_t *logctx) {
        dns_fixedname_init(&fixed);
        obj = cfg_tuple_get(ent, "class");
        if (cfg_obj_isstring(obj)) {
-               DE_CONST(cfg_obj_asstring(obj), r.base);
+               r.base = UNCONST(cfg_obj_asstring(obj));
                r.length = strlen(r.base);
                tresult = dns_rdataclass_fromtext(&rdclass, &r);
                if (tresult != ISC_R_SUCCESS) {
@@ -118,7 +118,7 @@ check_orderent(const cfg_obj_t *ent, isc_log_t *logctx) {
 
        obj = cfg_tuple_get(ent, "type");
        if (cfg_obj_isstring(obj)) {
-               DE_CONST(cfg_obj_asstring(obj), r.base);
+               r.base = UNCONST(cfg_obj_asstring(obj));
                r.length = strlen(r.base);
                tresult = dns_rdatatype_fromtext(&rdtype, &r);
                if (tresult != ISC_R_SUCCESS) {
@@ -389,7 +389,7 @@ disabled_algorithms(const cfg_obj_t *disabled, isc_log_t *logctx) {
                isc_textregion_t r;
                dns_secalg_t alg;
 
-               DE_CONST(cfg_obj_asstring(cfg_listelt_value(element)), r.base);
+               r.base = UNCONST(cfg_obj_asstring(cfg_listelt_value(element)));
                r.length = strlen(r.base);
 
                tresult = dns_secalg_fromtext(&alg, &r);
@@ -434,7 +434,7 @@ disabled_ds_digests(const cfg_obj_t *disabled, isc_log_t *logctx) {
                isc_textregion_t r;
                dns_dsdigest_t digest;
 
-               DE_CONST(cfg_obj_asstring(cfg_listelt_value(element)), r.base);
+               r.base = UNCONST(cfg_obj_asstring(cfg_listelt_value(element)));
                r.length = strlen(r.base);
 
                /* works with a numeric argument too */
@@ -2402,7 +2402,7 @@ validate_remotes(const char *list, const cfg_obj_t *obj,
        isc_symtab_t *symtab = NULL;
        isc_symvalue_t symvalue;
        const cfg_listelt_t *element;
-       const cfg_listelt_t **stack = NULL;
+       cfg_listelt_t **stack = NULL;
        uint32_t stackcount = 0, pushed = 0;
        const cfg_obj_t *listobj;
 
@@ -2519,16 +2519,13 @@ resume:
                        oldsize = stackcount * sizeof(*stack);
                        newstack = isc_mem_get(mctx, newsize);
                        if (stackcount != 0) {
-                               void *ptr;
-
-                               DE_CONST(stack, ptr);
                                memmove(newstack, stack, oldsize);
-                               isc_mem_put(mctx, ptr, oldsize);
+                               isc_mem_put(mctx, stack, oldsize);
                        }
                        stack = newstack;
                        stackcount = newlen;
                }
-               stack[pushed++] = cfg_list_next(element);
+               stack[pushed++] = UNCONST(cfg_list_next(element));
                goto newlist;
        }
        if (pushed != 0) {
@@ -2536,10 +2533,7 @@ resume:
                goto resume;
        }
        if (stack != NULL) {
-               void *ptr;
-
-               DE_CONST(stack, ptr);
-               isc_mem_put(mctx, ptr, stackcount * sizeof(*stack));
+               isc_mem_put(mctx, stack, stackcount * sizeof(*stack));
        }
        isc_symtab_destroy(&symtab);
        *countp = count;
@@ -2665,7 +2659,7 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
                case dns_ssumatchtype_external:
                case dns_ssumatchtype_local:
                        if (tresult == ISC_R_SUCCESS) {
-                               DE_CONST(str, r.base);
+                               r.base = UNCONST(str);
                                r.length = strlen(str);
                                tresult = dns_rdatatype_fromtext(&type, &r);
                        }
@@ -2689,7 +2683,7 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
                        const char *bracket;
 
                        typeobj = cfg_listelt_value(element2);
-                       DE_CONST(cfg_obj_asstring(typeobj), r.base);
+                       r.base = UNCONST(cfg_obj_asstring(typeobj));
 
                        bracket = strchr(r.base, '(' /*)*/);
                        if (bracket != NULL) {
@@ -2969,7 +2963,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
        if (cfg_obj_isstring(obj)) {
                isc_textregion_t r;
 
-               DE_CONST(cfg_obj_asstring(obj), r.base);
+               r.base = UNCONST(cfg_obj_asstring(obj));
                r.length = strlen(r.base);
                result = dns_rdataclass_fromtext(&zclass, &r);
                if (result != ISC_R_SUCCESS) {
@@ -6019,7 +6013,7 @@ isccfg_check_namedconf(const cfg_obj_t *config, unsigned int flags,
                if (cfg_obj_isstring(vclassobj)) {
                        isc_textregion_t r;
 
-                       DE_CONST(cfg_obj_asstring(vclassobj), r.base);
+                       r.base = UNCONST(cfg_obj_asstring(vclassobj));
                        r.length = strlen(r.base);
                        tresult = dns_rdataclass_fromtext(&vclass, &r);
                        if (tresult != ISC_R_SUCCESS) {
index 4e384e0470f4a3e698870190ca79bbdb1df00cef..e0d362870f0514f4bbb62744c7b225ccfc343e28 100644 (file)
@@ -63,7 +63,7 @@ parse_duration(const char *str) {
        isc_result_t result;
        isc_textregion_t tr;
 
-       DE_CONST(str, tr.base);
+       tr.base = UNCONST(str);
        tr.length = strlen(tr.base);
        result = isccfg_parse_duration(&tr, &duration);
        if (result == ISC_R_SUCCESS) {
@@ -332,7 +332,7 @@ add_digest(dns_kasp_t *kasp, const cfg_obj_t *digest, isc_log_t *logctx) {
        dns_dsdigest_t alg;
        const char *str = cfg_obj_asstring(digest);
 
-       DE_CONST(str, r.base);
+       r.base = UNCONST(str);
        r.length = strlen(str);
        result = dns_dsdigest_fromtext(&alg, &r);
        if (result != ISC_R_SUCCESS) {
index ac8ae02868958cdf660a5fe84bf0f1970e5a6919..eea42150bd2ab09687c276e7dba79c5c0b2b2ba2 100644 (file)
@@ -91,11 +91,9 @@ str2name(const char *namestr) {
        static dns_fixedname_t fname;
        static dns_name_t *name;
        static isc_buffer_t namebuf;
-       void *deconst_namestr;
 
        name = dns_fixedname_initname(&fname);
-       DE_CONST(namestr, deconst_namestr); /* OK, since we don't modify it */
-       isc_buffer_init(&namebuf, deconst_namestr, strlen(deconst_namestr));
+       isc_buffer_init(&namebuf, UNCONST(namestr), strlen(namestr));
        isc_buffer_add(&namebuf, strlen(namestr));
        assert_int_equal(
                dns_name_fromtext(name, &namebuf, dns_rootname, 0, NULL),
index 21879da023439edc4d3075f4d541cafc8b12d3cd..84d1b4cad0f31b377697e5fe52779ce1bec97743 100644 (file)
@@ -78,7 +78,7 @@ copy_params(nsec3param_rdata_test_params_t from, dns_rdata_nsec3param_t *to,
        if (from.salt == NULL) {
                to->salt = NULL;
        } else if (strcmp(from.salt, "-") == 0) {
-               DE_CONST("-", to->salt);
+               to->salt = (unsigned char *)"-";
        } else {
                decode_salt(from.salt, saltbuf, saltlen);
                to->salt = saltbuf;