Commit 90adbb5f authored by Mark Andrews's avatar Mark Andrews
Browse files

Remove various "enumerated type mixed with another type" warnings.

More still to be removed.
#define ISC_TF(x) to covert logical result to isc_boolean_t
parent 6b44a05a
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
*/
/* $Id: dnssec-keygen.c,v 1.6 1999/10/29 08:27:34 marka Exp $ */
/* $Id: dnssec-keygen.c,v 1.7 1999/10/29 12:56:51 marka Exp $ */
#include <config.h>
......@@ -257,7 +257,7 @@ main(int argc, char **argv) {
static isc_boolean_t
dsa_size_ok(int size) {
return (size >= 512 && size <= 1024 && size % 64 == 0);
return (ISC_TF(size >= 512 && size <= 1024 && size % 64 == 0));
}
static void
......
......@@ -134,9 +134,9 @@ iszonekey(signer_key_t *key, dns_db_t *db) {
result = dns_name_totext(dns_db_origin(db), ISC_FALSE, &b);
check_result(result, "dns_name_totext()");
return (strcasecmp(dst_key_name(key->key), origin) == 0 &&
return (ISC_TF(strcasecmp(dst_key_name(key->key), origin) == 0 &&
(dst_key_flags(key->key) & DNS_KEYFLAG_OWNERMASK) ==
DNS_KEYOWNER_ZONE);
DNS_KEYOWNER_ZONE));
}
static signer_key_t *
......@@ -208,7 +208,7 @@ setverifies(dns_name_t *name, dns_rdataset_t *set, signer_key_t *key,
dns_rdata_t *sig)
{
isc_result_t result = dns_dnssec_verify(name, set, key->key, mctx, sig);
return (result == ISC_R_SUCCESS);
return (ISC_TF(result == ISC_R_SUCCESS));
}
#define allocbufferandrdata \
......@@ -264,8 +264,8 @@ signset(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
result = dns_rdata_tostruct(&oldsigrdata, &sig, mctx);
check_result(result, "dns_rdata_tostruct");
expired = (now + cycle > sig.timeexpire);
future = (now < sig.timesigned);
expired = ISC_TF(now + cycle > sig.timeexpire);
future = ISC_TF(now < sig.timesigned);
key = keythatsigned(&sig);
......@@ -430,7 +430,7 @@ signname(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
isc_boolean_t atorigin = ISC_FALSE, isdelegation = ISC_FALSE;
origin = dns_db_origin(db);
atorigin = (dns_name_compare(name, origin) == 0);
atorigin = ISC_TF(dns_name_compare(name, origin) == 0);
if (!atorigin) {
dns_rdataset_init(&nsset);
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
*/
/* $Id: keygen.c,v 1.6 1999/10/29 08:27:34 marka Exp $ */
/* $Id: keygen.c,v 1.7 1999/10/29 12:56:51 marka Exp $ */
#include <config.h>
......@@ -257,7 +257,7 @@ main(int argc, char **argv) {
static isc_boolean_t
dsa_size_ok(int size) {
return (size >= 512 && size <= 1024 && size % 64 == 0);
return (ISC_TF(size >= 512 && size <= 1024 && size % 64 == 0));
}
static void
......
......@@ -120,7 +120,7 @@ test_master(char *testfile, char *origin, char *class, dns_result_t exp_result)
&dns_origin,
&dns_origin,
rdataclass,
1,
ISC_TRUE,
&soacount,
&nscount,
&callbacks,
......
......@@ -134,9 +134,9 @@ iszonekey(signer_key_t *key, dns_db_t *db) {
result = dns_name_totext(dns_db_origin(db), ISC_FALSE, &b);
check_result(result, "dns_name_totext()");
return (strcasecmp(dst_key_name(key->key), origin) == 0 &&
return (ISC_TF(strcasecmp(dst_key_name(key->key), origin) == 0 &&
(dst_key_flags(key->key) & DNS_KEYFLAG_OWNERMASK) ==
DNS_KEYOWNER_ZONE);
DNS_KEYOWNER_ZONE));
}
static signer_key_t *
......@@ -208,7 +208,7 @@ setverifies(dns_name_t *name, dns_rdataset_t *set, signer_key_t *key,
dns_rdata_t *sig)
{
isc_result_t result = dns_dnssec_verify(name, set, key->key, mctx, sig);
return (result == ISC_R_SUCCESS);
return (ISC_TF(result == ISC_R_SUCCESS));
}
#define allocbufferandrdata \
......@@ -264,8 +264,8 @@ signset(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
result = dns_rdata_tostruct(&oldsigrdata, &sig, mctx);
check_result(result, "dns_rdata_tostruct");
expired = (now + cycle > sig.timeexpire);
future = (now < sig.timesigned);
expired = ISC_TF(now + cycle > sig.timeexpire);
future = ISC_TF(now < sig.timesigned);
key = keythatsigned(&sig);
......@@ -430,7 +430,7 @@ signname(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
isc_boolean_t atorigin = ISC_FALSE, isdelegation = ISC_FALSE;
origin = dns_db_origin(db);
atorigin = (dns_name_compare(name, origin) == 0);
atorigin = ISC_TF(dns_name_compare(name, origin) == 0);
if (!atorigin) {
dns_rdataset_init(&nsset);
......
......@@ -41,17 +41,20 @@
*** TYPES
***/
#define ordering_nametable_size \
(sizeof (ordering_nametable) / sizeof (struct dns_c_pvt_ont))
static struct dns_c_pvt_ont {
dns_c_ordering_t val;
const char *strval;
} ordering_nametable[] = {
{ dns_c_ordering_fixed, "fixed" },
{ dns_c_ordering_random, "random" },
{ dns_c_ordering_cyclic, "cyclic" },
{ 0, NULL }
{ dns_c_ordering_cyclic, "cyclic" }
};
#define log_severity_nametable_size \
(sizeof (log_severity_nametable) / sizeof (struct dns_c_pvt_lsnt))
static struct dns_c_pvt_lsnt {
dns_c_logseverity_t val;
const char *strval;
......@@ -62,8 +65,7 @@ static struct dns_c_pvt_lsnt {
{ dns_c_log_notice, "notice" },
{ dns_c_log_warn, "warning" },
{ dns_c_log_debug, "debug" },
{ dns_c_log_dynamic, "dynamic" },
{ 0, NULL, }
{ dns_c_log_dynamic, "dynamic" }
};
......@@ -105,6 +107,8 @@ static struct dsn_c_pvt_sfnt {
};
#define category_nametable_size \
(sizeof (category_nametable) / sizeof(struct dns_c_pvt_cntable))
static struct dns_c_pvt_cntable {
dns_c_category_t val;
const char *strval;
......@@ -131,8 +135,7 @@ static struct dns_c_pvt_cntable {
{ dns_c_cat_maint, "maintenance" },
{ dns_c_cat_load, "load" },
{ dns_c_cat_respchecks, "response-checks" },
{ dns_c_cat_control, "control" },
{ 0, NULL }
{ dns_c_cat_control, "control" }
};
......@@ -240,12 +243,12 @@ dns_c_printtabs(isc_log_t *lctx, FILE *fp, int count)
isc_result_t
dns_c_string2ordering(isc_log_t *lctx, char *name, dns_c_ordering_t *ordering)
{
int i;
unsigned int i;
isc_result_t rval = ISC_R_FAILURE;
(void) lctx;
for (i = 0 ; ordering_nametable[i].strval != NULL ; i++) {
for (i = 0 ; i < ordering_nametable_size ; i++) {
if (strcmp(ordering_nametable[i].strval, name) == 0) {
*ordering = ordering_nametable[i].val;
rval = ISC_R_SUCCESS;
......@@ -261,12 +264,12 @@ const char *
dns_c_ordering2string(isc_log_t *lctx, dns_c_ordering_t ordering,
isc_boolean_t printable)
{
int i;
unsigned int i;
const char *rval = NULL;
(void) lctx;
for (i = 0 ; ordering_nametable[i].strval != NULL ; i++) {
for (i = 0 ; i < ordering_nametable_size ; i++) {
if (ordering_nametable[i].val == ordering) {
rval = ordering_nametable[i].strval;
break;
......@@ -281,12 +284,12 @@ const char *
dns_c_logseverity2string(isc_log_t *lctx, dns_c_logseverity_t severity,
isc_boolean_t printable)
{
int i;
unsigned int i;
const char *rval = NULL;
(void) lctx;
for (i = 0 ; log_severity_nametable[i].strval != NULL ; i++) {
for (i = 0 ; i < log_severity_nametable_size ; i++) {
if (log_severity_nametable[i].val == severity) {
rval = log_severity_nametable[i].strval;
break;
......@@ -301,14 +304,14 @@ isc_result_t
dns_c_string2logseverity(isc_log_t *lctx, const char *string,
dns_c_logseverity_t *result)
{
int i;
unsigned int i;
isc_result_t rval = ISC_R_FAILURE;
(void) lctx;
REQUIRE(result != NULL);
for (i = 0 ; log_severity_nametable[i].strval != NULL ; i++) {
for (i = 0 ; i < log_severity_nametable_size ; i++) {
if (strcmp(log_severity_nametable[i].strval, string) == 0) {
*result = log_severity_nametable[i].val;
rval = ISC_R_SUCCESS;
......@@ -324,12 +327,12 @@ const char *
dns_c_category2string(isc_log_t *lctx, dns_c_category_t cat,
isc_boolean_t printable)
{
int i;
unsigned int i;
const char *rval = NULL;
(void) lctx;
for (i = 0 ; category_nametable[i].strval != NULL ; i++) {
for (i = 0 ; i < category_nametable_size ; i++) {
if (category_nametable[i].val == cat) {
rval = category_nametable[i].strval;
break;
......@@ -344,14 +347,14 @@ isc_result_t
dns_c_string2category(isc_log_t *lctx, const char *string,
dns_c_category_t *category)
{
int i;
unsigned int i;
isc_result_t rval = ISC_R_FAILURE;
(void) lctx;
REQUIRE (category != NULL);
for (i = 0 ; category_nametable[i].strval != NULL ; i++) {
for (i = 0 ; i < category_nametable_size ; i++) {
if (strcmp(category_nametable[i].strval, string) == 0) {
*category = category_nametable[i].val;
rval = ISC_R_SUCCESS;
......
......@@ -86,7 +86,8 @@ dns_c_ipmatchelement_isneg(isc_log_t *lctx,
REQUIRE(DNS_IPMELEM_VALID(elem));
return ((elem->flags & DNS_C_IPMATCH_NEGATE) == DNS_C_IPMATCH_NEGATE);
return (ISC_TF((elem->flags & DNS_C_IPMATCH_NEGATE) ==
DNS_C_IPMATCH_NEGATE));
}
......@@ -236,10 +237,10 @@ dns_c_ipmatchelement_equal(dns_c_ipmatchelement_t *e1,
break;
case dns_c_ipmatch_key:
return (strcmp(e1->u.key, e2->u.key) == 0);
return (ISC_TF(strcmp(e1->u.key, e2->u.key) == 0));
case dns_c_ipmatch_acl:
return (strcmp(e1->u.aclname, e2->u.aclname) == 0);
return (ISC_TF(strcmp(e1->u.aclname, e2->u.aclname) == 0));
case dns_c_ipmatch_none:
break;
......
......@@ -692,10 +692,10 @@ dns_c_pubkey_equal(dns_c_pubkey_t *k1, dns_c_pubkey_t *k2) {
return (ISC_TRUE);
if (k1 == NULL || k2 == NULL)
return (ISC_FALSE);
return (k1->flags == k2->flags &&
return (ISC_TF(k1->flags == k2->flags &&
k1->protocol == k2->protocol &&
k1->algorithm == k2->algorithm &&
strcmp(k1->key, k2->key) == 0);
strcmp(k1->key, k2->key) == 0));
}
void
......
......@@ -36,7 +36,7 @@
#define DNS_C_CLEARBIT(bit, flags) \
(*(flags) &= ~((dns_c_setbits_t)1 << (bit)))
#define DNS_C_CHECKBIT(bit,flags) \
((*(flags) & ((dns_c_setbits_t)1 << (bit))) == ((dns_c_setbits_t)1 << (bit)))
ISC_TF((*(flags) & ((dns_c_setbits_t)1 << (bit))) == ((dns_c_setbits_t)1 << (bit)))
#define DNS_C_VALID_STRUCT(p,m) ((p) != NULL && (p)->magic == m)
......
......@@ -18,6 +18,7 @@
#include <config.h>
#include <isc/assertions.h>
#include <isc/boolean.h>
#include <isc/error.h>
#include <isc/result.h>
#include <isc/timer.h>
......@@ -1522,7 +1523,7 @@ check_related(void *arg, dns_name_t *addname, dns_rdatatype_t type) {
addname, dns_rdatatype_any, 0, &name,
NULL);
if (result == ISC_R_SUCCESS) {
external = !dns_name_issubdomain(name, &fctx->domain);
external = ISC_TF(!dns_name_issubdomain(name, &fctx->domain));
if (type == dns_rdatatype_a) {
for (rdataset = ISC_LIST_HEAD(name->list);
rdataset != NULL;
......@@ -1846,7 +1847,7 @@ answer_response(fetchctx_t *fctx) {
while (!done && result == ISC_R_SUCCESS) {
name = NULL;
dns_message_currentname(message, DNS_SECTION_ANSWER, &name);
external = !dns_name_issubdomain(name, &fctx->domain);
external = ISC_TF(!dns_name_issubdomain(name, &fctx->domain));
if (dns_name_equal(name, qname)) {
for (rdataset = ISC_LIST_HEAD(name->list);
rdataset != NULL;
......@@ -2107,7 +2108,7 @@ answer_response(fetchctx_t *fctx) {
while (!done && result == ISC_R_SUCCESS) {
name = NULL;
dns_message_currentname(message, DNS_SECTION_AUTHORITY, &name);
external = !dns_name_issubdomain(name, &fctx->domain);
external = ISC_TF(!dns_name_issubdomain(name, &fctx->domain));
if (!external) {
/*
* We expect to find NS or SIG NS rdatasets, and
......
......@@ -19,7 +19,7 @@
/*
* Principal Author: Brian Wellington
* $Id: bsafe_link.c,v 1.10 1999/10/20 22:14:14 bwelling Exp $
* $Id: bsafe_link.c,v 1.11 1999/10/29 12:56:56 marka Exp $
*/
#include <config.h>
......@@ -392,7 +392,7 @@ dst_bsafe_verify(const unsigned int mode, dst_key_t *key, void **context,
static isc_boolean_t
dst_bsafe_isprivate(const dst_key_t *key) {
RSA_Key *rkey = (RSA_Key *) key->opaque;
return (rkey != NULL && rkey->rk_Private_Key != NULL);
return (ISC_TF(rkey != NULL && rkey->rk_Private_Key != NULL));
}
......
......@@ -19,7 +19,7 @@
/*
* Principal Author: Brian Wellington
* $Id: openssl_link.c,v 1.11 1999/10/20 22:14:14 bwelling Exp $
* $Id: openssl_link.c,v 1.12 1999/10/29 12:56:57 marka Exp $
*/
#include <config.h>
......@@ -252,7 +252,7 @@ dst_openssl_verify(const unsigned int mode, dst_key_t *key, void **context,
static isc_boolean_t
dst_openssl_isprivate(const dst_key_t *key) {
DSA *dsa = (DSA *) key->opaque;
return (dsa != NULL && dsa->priv_key != NULL);
return (ISC_TF(dsa != NULL && dsa->priv_key != NULL));
}
......
......@@ -19,7 +19,7 @@
/*
* Principal Author: Brian Wellington
* $Id: openssldh_link.c,v 1.5 1999/10/27 20:46:33 bwelling Exp $
* $Id: openssldh_link.c,v 1.6 1999/10/29 12:56:57 marka Exp $
*/
#include <config.h>
......@@ -158,7 +158,7 @@ dst_openssldh_computesecret(const dst_key_t *pub, const dst_key_t *priv,
static isc_boolean_t
dst_openssldh_isprivate(const dst_key_t *key) {
DH *dh = (DH *) key->opaque;
return (dh != NULL && dh->priv_key != NULL);
return (ISC_TF(dh != NULL && dh->priv_key != NULL));
}
......
......@@ -77,23 +77,23 @@ dns_ttl_totext(isc_uint32_t src, isc_boolean_t verbose,
x = 0;
if (weeks != 0) {
RETERR(ttlfmt(weeks, "week", verbose, (x > 0), target));
RETERR(ttlfmt(weeks, "week", verbose, ISC_TF(x > 0), target));
x++;
}
if (days != 0) {
RETERR(ttlfmt(days, "day", verbose, (x > 0), target));
RETERR(ttlfmt(days, "day", verbose, ISC_TF(x > 0), target));
x++;
}
if (hours != 0) {
RETERR(ttlfmt(hours, "hour", verbose, (x > 0), target));
RETERR(ttlfmt(hours, "hour", verbose, ISC_TF(x > 0), target));
x++;
}
if (mins != 0) {
RETERR(ttlfmt(mins, "minute", verbose, (x > 0), target));
RETERR(ttlfmt(mins, "minute", verbose, ISC_TF(x > 0), target));
x++;
}
if (secs != 0 || (weeks == 0 && days == 0 && hours == 0 && mins == 0)) {
RETERR(ttlfmt(secs, "second", verbose, (x > 0), target));
RETERR(ttlfmt(secs, "second", verbose, ISC_TF(x > 0), target));
x++;
}
INSIST (x > 0);
......
......@@ -26,6 +26,7 @@ typedef enum { isc_boolean_false = 0, isc_boolean_true = 1 } isc_boolean_t;
#define ISC_FALSE isc_boolean_false
#define ISC_TRUE isc_boolean_true
#define ISC_TF(x) ((x) ? ISC_TRUE : ISC_FALSE)
ISC_LANG_ENDDECLS
......
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