m_property: simplify some code

This commit is contained in:
wm4 2014-02-24 20:03:45 +01:00
parent 43ad09393c
commit b097d76281
1 changed files with 6 additions and 10 deletions

View File

@ -183,16 +183,12 @@ int m_property_do(struct mp_log *log, const m_option_t *prop_list,
case M_PROPERTY_SET: {
if (!log)
return M_PROPERTY_ERROR;
if (!opt.type->clamp) {
mp_warn(log, "Property '%s' without clamp().\n", name);
} else {
m_option_copy(&opt, &val, arg);
r = opt.type->clamp(&opt, arg);
m_option_free(&opt, &val);
if (r != 0) {
mp_err(log, "Property '%s': invalid value.\n", name);
return M_PROPERTY_ERROR;
}
m_option_copy(&opt, &val, arg);
r = opt.type->clamp ? opt.type->clamp(&opt, arg) : 0;
m_option_free(&opt, &val);
if (r != 0) {
mp_err(log, "Property '%s': invalid value.\n", name);
return M_PROPERTY_ERROR;
}
return do_action(prop_list, name, M_PROPERTY_SET, arg, ctx);
}