Code cleanup in ReplaceRule::create_from()

Code cleanup in ReplaceRule::create_from()
This commit is contained in:
MassimilianoPinto
2017-07-07 17:57:02 +02:00
parent deef6bb030
commit e70852d10b

View File

@ -653,33 +653,30 @@ auto_ptr<MaskingRules::Rule> MaskingRules::ReplaceRule::create_from(json_t* pRul
if (pReplace && pWith) if (pReplace && pWith)
{ {
bool ok = true; bool ok = true;
const char *err = NULL;
// Check replace
if (!json_is_object(pReplace)) if (!json_is_object(pReplace))
{ {
MXS_ERROR("A masking rule contains a '%s' key, but the value is not an object.", err = KEY_REPLACE;
KEY_REPLACE);
ok = false;
} }
// Check with
if (!json_is_object(pWith)) if (!json_is_object(pWith))
{ {
MXS_ERROR("A masking rule contains a '%s' key, but the value is not an object.", err = KEY_WITH;
KEY_WITH); }
ok = false; if (err)
{
MXS_ERROR("A masking rule contains a '%s' key, "
"but the value is not an object.",
err);
return sRule;
} }
if (pApplies_to && !json_is_array(pApplies_to)) // Check for pApplies_to and pExempted
if (!validate_user_rules(pApplies_to, pExempted))
{ {
MXS_ERROR("A masking rule contains a '%s' key, but the value is not an array.", return sRule;
KEY_APPLIES_TO);
ok = false;
}
if (pExempted && !json_is_array(pExempted))
{
MXS_ERROR("A masking rule contains a '%s' key, but the value is not an array.",
KEY_EXEMPTED);
ok = false;
} }
if (ok) if (ok)