spatch --sp-file cocci/set_if_not_null.spatch --use-gitgrep --dir "." --include-headers --in-place
result = isc_getaddresses(host, 0, sockaddrs, DIG_MAX_ADDRESSES,
&count);
isc_loopmgr_nonblocking(loopmgr);
- if (resultp != NULL) {
- *resultp = result;
- }
+ SET_IF_NOT_NULL(resultp, result);
if (result != ISC_R_SUCCESS) {
if (resultp == NULL) {
fatal("couldn't get address for '%s': %s", host,
struct tm tm;
if (isnone(str)) {
- if (setp != NULL) {
- *setp = false;
- }
+ SET_IF_NOT_NULL(setp, false);
return ((isc_stdtime_t)0);
}
- if (setp != NULL) {
- *setp = true;
- }
+ SET_IF_NOT_NULL(setp, true);
if ((str[0] == '0' || str[0] == '-') && str[1] == '\0') {
return ((isc_stdtime_t)0);
} else {
bits = algorithms[i].size;
}
- if (typep != NULL) {
- *typep = algorithms[i].type;
- }
- if (digestbits != NULL) {
- *digestbits = bits;
- }
+ SET_IF_NOT_NULL(typep, algorithms[i].type);
+ SET_IF_NOT_NULL(digestbits, bits);
return (ISC_R_SUCCESS);
}
rdatap += 4;
used += (4 * 5);
- if (rdlenp != NULL) {
- *rdlenp = used;
- }
+ SET_IF_NOT_NULL(rdlenp, used);
return (true);
}
tptr = tmps;
- if (dstlen != NULL) {
- *dstlen = 0;
- }
+ SET_IF_NOT_NULL(dstlen, 0);
while (tptr && *tptr) {
tok = strsep(&tptr, ".");
*ttlp = 3600;
}
- if (typep != NULL) {
- *typep = this_rr->type;
- }
+ SET_IF_NOT_NULL(typep, this_rr->type);
if (rrp != NULL) {
uint8_t *copy_src = NULL, *nrdata = NULL;
trsp->rstack[0].result.next_rr = this_rr->rrn;
last_result->rridx++;
} else {
- if (typep != NULL) {
- *typep = ns_t_invalid;
- }
+ SET_IF_NOT_NULL(typep, ns_t_invalid);
if (rrp != NULL) {
*rrp = NULL;
FILE *f = NULL;
int result = -1;
- if (errp != NULL) {
- *errp = NULL;
- }
+ SET_IF_NOT_NULL(errp, NULL);
f = fopen(fname, "r");
if (f == NULL) {
double *lowp, double *highp, double *discountp) {
REQUIRE(DNS_ADB_VALID(adb));
- if (quotap != NULL) {
- *quotap = adb->quota;
- }
+ SET_IF_NOT_NULL(quotap, adb->quota);
- if (freqp != NULL) {
- *freqp = adb->atr_freq;
- }
+ SET_IF_NOT_NULL(freqp, adb->atr_freq);
- if (lowp != NULL) {
- *lowp = adb->atr_low;
- }
+ SET_IF_NOT_NULL(lowp, adb->atr_low);
- if (highp != NULL) {
- *highp = adb->atr_high;
- }
+ SET_IF_NOT_NULL(highp, adb->atr_high);
- if (discountp != NULL) {
- *discountp = adb->atr_discount;
- }
+ SET_IF_NOT_NULL(discountp, adb->atr_discount);
}
static bool
}
}
- if (have_ksk != NULL) {
- *have_ksk = hksk;
- }
- if (have_zsk != NULL) {
- *have_zsk = hzsk;
- }
+ SET_IF_NOT_NULL(have_ksk, hksk);
+ SET_IF_NOT_NULL(have_zsk, hzsk);
return (hksk && hzsk);
}
flags = isc_buffer_getuint16(&buffer);
flags &= DNS_MESSAGE_FLAG_MASK;
- if (flagsp != NULL) {
- *flagsp = flags;
- }
- if (idp != NULL) {
- *idp = id;
- }
+ SET_IF_NOT_NULL(flagsp, flags);
+ SET_IF_NOT_NULL(idp, id);
return (ISC_R_SUCCESS);
}
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(owner == NULL || *owner == NULL);
- if (owner != NULL) {
- *owner = msg->tsigname;
- }
+ SET_IF_NOT_NULL(owner, msg->tsigname);
return (msg->tsig);
}
return (DNS_R_BADALG);
}
- if (hash_length != NULL) {
- *hash_length = len;
- }
+ SET_IF_NOT_NULL(hash_length, len);
/* convert the hash to base32hex non-padded */
region.base = rethash;
void
RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e,
const BIGNUM **d) {
- if (n != NULL) {
- *n = r->n;
- }
- if (e != NULL) {
- *e = r->e;
- }
- if (d != NULL) {
- *d = r->d;
- }
+ SET_IF_NOT_NULL(n, r->n);
+ SET_IF_NOT_NULL(e, r->e);
+ SET_IF_NOT_NULL(d, r->d);
}
void
RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) {
- if (p != NULL) {
- *p = r->p;
- }
- if (q != NULL) {
- *q = r->q;
- }
+ SET_IF_NOT_NULL(p, r->p);
+ SET_IF_NOT_NULL(q, r->q);
}
void
RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1,
const BIGNUM **iqmp) {
- if (dmp1 != NULL) {
- *dmp1 = r->dmp1;
- }
- if (dmq1 != NULL) {
- *dmq1 = r->dmq1;
- }
- if (iqmp != NULL) {
- *iqmp = r->iqmp;
- }
+ SET_IF_NOT_NULL(dmp1, r->dmp1);
+ SET_IF_NOT_NULL(dmq1, r->dmq1);
+ SET_IF_NOT_NULL(iqmp, r->iqmp);
}
int
/* From OpenSSL 1.1 */
void
ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) {
- if (pr != NULL) {
- *pr = sig->r;
- }
- if (ps != NULL) {
- *ps = sig->s;
- }
+ SET_IF_NOT_NULL(pr, sig->r);
+ SET_IF_NOT_NULL(ps, sig->s);
}
int
unsigned long
ERR_get_error_all(const char **file, int *line, const char **func,
const char **data, int *flags) {
- if (func != NULL) {
- *func = &err_empty_string;
- }
+ SET_IF_NOT_NULL(func, &err_empty_string);
return (ERR_get_error_line_data(file, line, data, flags));
}
#endif /* if !HAVE_ERR_GET_ERROR_ALL */
}
RWLOCK(&rbtversion->rwlock, isc_rwlocktype_read);
- if (records != NULL) {
- *records = rbtversion->records;
- }
+ SET_IF_NOT_NULL(records, rbtversion->records);
- if (xfrsize != NULL) {
- *xfrsize = rbtversion->xfrsize;
- }
+ SET_IF_NOT_NULL(xfrsize, rbtversion->xfrsize);
RWUNLOCK(&rbtversion->rwlock, isc_rwlocktype_read);
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
isc_textregion_consume(region, 1);
}
RETERR(uint16_tobuffer(ul, target));
- if (value != NULL) {
- *value = ul;
- }
+ SET_IF_NOT_NULL(value, ul);
return (ISC_R_SUCCESS);
}
result = dns_name_concatenate(&prefix, &dname.dname, tname,
NULL);
if (result == DNS_R_NAMETOOLONG) {
- if (chainingp != NULL) {
- *chainingp = true;
- }
+ SET_IF_NOT_NULL(chainingp, true);
return (true);
}
RUNTIME_CHECK(result == ISC_R_SUCCESS);
UNREACHABLE();
}
- if (chainingp != NULL) {
- *chainingp = true;
- }
+ SET_IF_NOT_NULL(chainingp, true);
if (view->denyanswernames == NULL) {
return (true);
REQUIRE(VALID_RESOLVER(resolver));
LOCK(&resolver->lock);
- if (cur != NULL) {
- *cur = resolver->spillat;
- }
- if (min != NULL) {
- *min = resolver->spillatmin;
- }
- if (max != NULL) {
- *max = resolver->spillatmax;
- }
+ SET_IF_NOT_NULL(cur, resolver->spillat);
+ SET_IF_NOT_NULL(min, resolver->spillatmin);
+ SET_IF_NOT_NULL(max, resolver->spillatmax);
UNLOCK(&resolver->lock);
}
dns_rdata_reset(&it->rdata);
dns_rdataset_current(&it->rdataset, &it->rdata);
- if (rdataset != NULL) {
- *rdataset = &it->rdataset;
- }
+ SET_IF_NOT_NULL(rdataset, &it->rdataset);
- if (rdata != NULL) {
- *rdata = &it->rdata;
- }
+ SET_IF_NOT_NULL(rdata, &it->rdata);
}
tsig_log(tkey, ISC_LOG_DEBUG(3), "statically configured");
}
- if (keyp != NULL) {
- *keyp = tkey;
- }
+ SET_IF_NOT_NULL(keyp, tkey);
return (ISC_R_SUCCESS);
cleanup_name:
if (result == ISC_R_SUCCESS || result == DNS_R_EMPTYNAME) {
*flag = true;
*cut = false;
- if (unsecure != NULL) {
- *unsecure = false;
- }
+ SET_IF_NOT_NULL(unsecure, false);
return (ISC_R_SUCCESS);
} else if (result == DNS_R_ZONECUT) {
*flag = true;
{
*flag = false;
*cut = false;
- if (unsecure != NULL) {
- *unsecure = false;
- }
+ SET_IF_NOT_NULL(unsecure, false);
return (ISC_R_SUCCESS);
} else {
/*
*/
*flag = false;
*cut = false;
- if (unsecure != NULL) {
- *unsecure = false;
- }
+ SET_IF_NOT_NULL(unsecure, false);
return (result);
}
}
UNREACHABLE();
}
- if (used != NULL) {
- *used = method;
- }
+ SET_IF_NOT_NULL(used, method);
return (new_serial);
}
*/
#define RANGE(a, min, max) (((a) < (min)) ? (min) : ((a) < (max) ? (a) : (max)))
-#define NSEC3REMOVE(x) (((x) & DNS_NSEC3FLAG_REMOVE) != 0)
+#define NSEC3REMOVE(x) (((x)&DNS_NSEC3FLAG_REMOVE) != 0)
/*%
* Key flags
dns_rdataset_disassociate(&rdataset);
success:
- if (nscount != NULL) {
- *nscount = count;
- }
- if (errors != NULL) {
- *errors = ecount;
- }
+ SET_IF_NOT_NULL(nscount, count);
+ SET_IF_NOT_NULL(errors, ecount);
result = ISC_R_SUCCESS;
}
dns_qpread_destroy(zt->multi, &qpr);
- if (sub != NULL) {
- *sub = tresult;
- }
+ SET_IF_NOT_NULL(sub, tresult);
return (result);
}
}
INSIST(node->key != NULL);
- if (valuep != NULL) {
- *valuep = node->value;
- }
+ SET_IF_NOT_NULL(valuep, node->value);
return (ISC_R_SUCCESS);
}
return (ISC_R_NOTFOUND);
}
- if (valuep != NULL) {
- *valuep = node->value;
- }
+ SET_IF_NOT_NULL(valuep, node->value);
return (ISC_R_SUCCESS);
}
ISC_BUFFER_PEEK_CHECK(b, sizeof(*valp));
uint8_t *cp = isc_buffer_current(b);
- if (valp != NULL) {
- *valp = (uint8_t)(cp[0]);
- }
+ SET_IF_NOT_NULL(valp, (uint8_t)(cp[0]));
return (ISC_R_SUCCESS);
}
uint8_t *cp = isc_buffer_current(b);
- if (valp != NULL) {
- *valp = ISC_U8TO16_BE(cp);
- }
+ SET_IF_NOT_NULL(valp, ISC_U8TO16_BE(cp));
return (ISC_R_SUCCESS);
}
uint8_t *cp = isc_buffer_current(b);
- if (valp != NULL) {
- *valp = ISC_U8TO32_BE(cp);
- }
+ SET_IF_NOT_NULL(valp, ISC_U8TO32_BE(cp));
return (ISC_R_SUCCESS);
}
uint8_t *cp = isc_buffer_current(b);
- if (valp != NULL) {
- *valp = ISC_U8TO48_BE(cp);
- }
+ SET_IF_NOT_NULL(valp, ISC_U8TO48_BE(cp));
return (ISC_R_SUCCESS);
}
atomic_init(&lctx->dynamic, lcfg->dynamic);
*lctxp = lctx;
- if (lcfgp != NULL) {
- *lcfgp = lcfg;
- }
+ SET_IF_NOT_NULL(lcfgp, lcfg);
}
void
uint32_t *keepalive, uint32_t *advertised) {
REQUIRE(VALID_NM(mgr));
- if (initial != NULL) {
- *initial = atomic_load_relaxed(&mgr->init);
- }
+ SET_IF_NOT_NULL(initial, atomic_load_relaxed(&mgr->init));
- if (idle != NULL) {
- *idle = atomic_load_relaxed(&mgr->idle);
- }
+ SET_IF_NOT_NULL(idle, atomic_load_relaxed(&mgr->idle));
- if (keepalive != NULL) {
- *keepalive = atomic_load_relaxed(&mgr->keepalive);
- }
+ SET_IF_NOT_NULL(keepalive, atomic_load_relaxed(&mgr->keepalive));
- if (advertised != NULL) {
- *advertised = atomic_load_relaxed(&mgr->advertised);
- }
+ SET_IF_NOT_NULL(advertised, atomic_load_relaxed(&mgr->advertised));
}
bool
result = isc__errno2result(errno);
}
}
- if (nret != NULL) {
- *nret = r;
- }
+ SET_IF_NOT_NULL(nret, r);
return (result);
}
if (r != nmemb) {
result = isc__errno2result(errno);
}
- if (nret != NULL) {
- *nret = r;
- }
+ SET_IF_NOT_NULL(nret, r);
return (result);
}
return (ISC_R_NOTFOUND);
}
- if (value != NULL) {
- *value = elt->value;
- }
+ SET_IF_NOT_NULL(value, elt->value);
return (ISC_R_SUCCESS);
}
return (ISC_R_NOTFOUND);
}
- if (value != NULL) {
- *value = elt->value;
- }
+ SET_IF_NOT_NULL(value, elt->value);
return (ISC_R_SUCCESS);
}
return (ISC_R_RANGE);
}
- if (portp != NULL) {
- *portp = (in_port_t)cfg_obj_asuint32(portobj);
- }
+ SET_IF_NOT_NULL(portp, (in_port_t)cfg_obj_asuint32(portobj));
return (ISC_R_SUCCESS);
}
approved:
/* Transfer ownership, if necessary. */
- if (versionp != NULL) {
- *versionp = dbversion->version;
- }
+ SET_IF_NOT_NULL(versionp, dbversion->version);
return (ISC_R_SUCCESS);
}
mname = NULL;
}
- if (mnamep != NULL) {
- *mnamep = mname;
- }
+ SET_IF_NOT_NULL(mnamep, mname);
CTRACE(ISC_LOG_DEBUG(3), "query_isduplicate: false: done");
return (false);