Fix default argument in matches_if_present filters (#8649)

Due to confusion between NULL and std::nullopt, these filters used
zero instead of nullopt as the default value for this argument. However,
the effects are limited to experimental_filter_ability and that tag's _active
sibling, and result in a false positive when the filter matches a value of
zero. With those constraints, I (octalot) am happy to apply it to stable.

This was detected as a compilation error when building with musl libc,
thanks to iFoundSilentHouse for finding and reporting it.
This commit is contained in:
newfrenchy83 2024-03-30 13:34:30 +01:00 committed by GitHub
parent f930418827
commit 21e2ec5847
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,8 +40,8 @@ bool bool_matches_if_present(const config& filter, const config& cfg, const std:
*
* Always returns true if the filter puts no restriction on the value of @a cfg[@a attribute].
*/
bool double_matches_if_present(const config& filter, const config& cfg, const std::string& attribute, std::optional<double> def = NULL);
bool int_matches_if_present(const config& filter, const config& cfg, const std::string& attribute, std::optional<int> def = NULL);
bool double_matches_if_present(const config& filter, const config& cfg, const std::string& attribute, std::optional<double> def = std::nullopt);
bool int_matches_if_present(const config& filter, const config& cfg, const std::string& attribute, std::optional<int> def = std::nullopt);
/**
* Restricts filters to only looking for values that are zero or more.
@ -62,7 +62,7 @@ bool unsigned_matches_if_present(const config& filter, const config& cfg, const
* The function is named "negative" in case we later want to add a "reciprocal" for the "multiply"/"divide" pair.
*/
bool int_matches_if_present_or_negative(
const config& filter, const config& cfg, const std::string& attribute, const std::string& opposite, std::optional<int> def = NULL);
const config& filter, const config& cfg, const std::string& attribute, const std::string& opposite, std::optional<int> def = std::nullopt);
bool string_matches_if_present(
const config& filter, const config& cfg, const std::string& attribute, const std::string& def);