fix: test: Various coccinelle fixes

Merge branch 'mnowak/cocci-more-set-if-not-null-changes' into 'main'

See merge request isc-projects/bind9!9836
This commit is contained in:
Michal Nowak 2024-12-13 13:48:20 +00:00
commit f379e1bef9
8 changed files with 21 additions and 45 deletions

View file

@ -564,7 +564,13 @@ clang-format:
when: on_failure
coccinelle:
<<: *precheck_job
######################################################################
# Revert to using the "precheck_job" anchor after the "base" image is
# upgraded to Debian trixie, which has Coccinelle 1.2.
<<: *default_triggering_rules
<<: *debian_sid_amd64_image
stage: precheck
######################################################################
needs: []
script:
- util/check-cocci

View file

@ -460,9 +460,7 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
dns_secalg_t alg;
isc_stdtime_t now = isc_stdtime_now();
if (exact != NULL) {
*exact = false;
}
SET_IF_NOT_NULL(exact, false);
id = dst_key_id(dstkey);
rid = dst_key_rid(dstkey);

View file

@ -1,4 +1,4 @@
@@
@depends on !(file in "util/models.c") && !(file in "lib/dns/sdlz.c")@
@@
- unsigned

View file

@ -2551,9 +2551,7 @@ dns_message_findname(dns_message_t *msg, dns_section_t section,
return result;
}
if (name != NULL) {
*name = foundname;
}
SET_IF_NOT_NULL(name, foundname);
/*
* And now look for the type.

View file

@ -138,12 +138,8 @@ dns_private_chains(dns_db_t *db, dns_dbversion_t *ver,
if (dns_rdataset_isassociated(&nsecset) &&
dns_rdataset_isassociated(&nsec3paramset))
{
if (build_nsec != NULL) {
*build_nsec = true;
}
if (build_nsec3 != NULL) {
*build_nsec3 = true;
}
SET_IF_NOT_NULL(build_nsec, true);
SET_IF_NOT_NULL(build_nsec3, true);
goto success;
}
@ -160,12 +156,8 @@ dns_private_chains(dns_db_t *db, dns_dbversion_t *ver,
* Look to see if we also need to be creating a NSEC3 chain.
*/
if (dns_rdataset_isassociated(&nsecset)) {
if (build_nsec != NULL) {
*build_nsec = true;
}
if (build_nsec3 != NULL) {
*build_nsec3 = false;
}
SET_IF_NOT_NULL(build_nsec, true);
SET_IF_NOT_NULL(build_nsec3, false);
if (!dns_rdataset_isassociated(&privateset)) {
goto success;
}
@ -194,12 +186,8 @@ dns_private_chains(dns_db_t *db, dns_dbversion_t *ver,
}
if (dns_rdataset_isassociated(&nsec3paramset)) {
if (build_nsec3 != NULL) {
*build_nsec3 = true;
}
if (build_nsec != NULL) {
*build_nsec = false;
}
SET_IF_NOT_NULL(build_nsec3, true);
SET_IF_NOT_NULL(build_nsec, false);
if (!dns_rdataset_isassociated(&privateset)) {
goto success;
}
@ -264,12 +252,8 @@ dns_private_chains(dns_db_t *db, dns_dbversion_t *ver,
goto success;
}
if (build_nsec != NULL) {
*build_nsec = false;
}
if (build_nsec3 != NULL) {
*build_nsec3 = false;
}
SET_IF_NOT_NULL(build_nsec, false);
SET_IF_NOT_NULL(build_nsec3, false);
if (!dns_rdataset_isassociated(&privateset)) {
goto success;
}

View file

@ -1599,9 +1599,7 @@ dns_view_issecuredomain(dns_view_t *view, const dns_name_t *name,
return result;
}
if (ntap != NULL) {
*ntap = false;
}
SET_IF_NOT_NULL(ntap, false);
if (checknta && secure && view->ntatable_priv != NULL &&
dns_ntatable_covered(view->ntatable_priv, now, name, anchor))
{

View file

@ -209,9 +209,7 @@ count_acl_elements(const cfg_obj_t *caml, const cfg_obj_t *cctx,
REQUIRE(count != NULL);
if (has_negative != NULL) {
*has_negative = false;
}
SET_IF_NOT_NULL(has_negative, false);
for (elt = cfg_list_first(caml); elt != NULL; elt = cfg_list_next(elt))
{

View file

@ -347,15 +347,9 @@ extract_qctx(void *arg, void *data, isc_result_t *resultp) {
* gets unwound.
*/
qctx = isc_mem_get(mctx, sizeof(*qctx));
if (qctx != NULL) {
memmove(qctx, (query_ctx_t *)arg, sizeof(*qctx));
}
memmove(qctx, (query_ctx_t *)arg, sizeof(*qctx));
qctxp = (query_ctx_t **)data;
/*
* If memory allocation failed, the supplied pointer will simply be set
* to NULL. We rely on the user of this hook to react properly.
*/
*qctxp = qctx;
*resultp = ISC_R_UNSET;