From d116e71d2c1a3e6d9bf3f72672130e544843efb3 Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Sat, 26 Mar 2022 23:48:15 +0100 Subject: [PATCH] Deprecation warning on 'singlepole' requirements not also checking 'alltemperate' See osdn #44181 Signed-off-by: Alina Lenk --- server/rssanity.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/server/rssanity.c b/server/rssanity.c index 426d47a3cf..40d866476e 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -387,6 +387,56 @@ static bool sanity_check_req_set(int reqs_of_type[], int local_reqs_of_type[], return TRUE; } +/************************************************************************** + Helper function: Sanity check potential 'singlepole' server setting + requirement in a requirement vector. + 'conjunctive' should be TRUE if the vector is an AND vector (all + requirements must be active), FALSE if it's a disjunctive (OR) vector. + + Returns TRUE iff everything ok. +**************************************************************************/ +static void +sanity_check_req_vec_singlepole(const struct requirement_vector *preqs, + bool conjunctive, const char *list_for) +{ + bool has_singlepole_req = FALSE; + + requirement_vector_iterate(preqs, preq) { + server_setting_id id; + struct setting *pset; + + if (preq->source.kind != VUT_SERVERSETTING) { + continue; + } + + id = ssetv_setting_get(preq->source.value.ssetval); + fc_assert_ret(server_setting_exists(id)); + pset = setting_by_number(id); + + if (pset == setting_by_name("singlepole")) { + has_singlepole_req = TRUE; + } else if (pset == setting_by_name("alltemperate") + && XOR(conjunctive, preq->present)) { + return; + } + } requirement_vector_iterate_end; + + if (!has_singlepole_req) { + /* all good */ + return; + } + + if (conjunctive) { + log_deprecation("%s: Requirement list containing 'singlepole' server" + " setting requirement should also have negated" + " (!present) 'alltemperate' requirement", list_for); + } else { + log_deprecation("%s: Disjunctive requirement list containing" + " 'singlepole' server setting requirement should also" + " have present 'alltemperate' requirement", list_for); + } +} + /************************************************************************** Sanity check requirement vector, including whether it's free of conflicting requirements. @@ -422,6 +472,8 @@ static bool sanity_check_req_vec(const struct requirement_vector *preqs, } } requirement_vector_iterate_end; + sanity_check_req_vec_singlepole(preqs, conjunctive, list_for); + problem = req_vec_get_first_contradiction(preqs, req_vec_vector_number, preqs); if (problem != NULL) { -- 2.17.1