1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvm2app: access params after its checked

Since params is checked for NULL, move code that dereferences
params after its check.
This commit is contained in:
Zdenek Kabelac 2014-02-09 21:36:02 +01:00
parent 38e457c478
commit c1faa4048a

View File

@ -757,17 +757,15 @@ struct lvm_property_value lvm_lv_params_get_property(
const lv_create_params_t params, const lv_create_params_t params,
const char *name) const char *name)
{ {
struct lvm_property_value rc = { struct lvm_property_value rc = { .is_valid = 0 };
.is_valid = 0
};
struct saved_env e = store_user_env(params->vg->cmd);
if (params && params->magic == LV_CREATE_PARAMS_MAGIC) { if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
struct saved_env e = store_user_env(params->vg->cmd);
rc = get_property(NULL, NULL, NULL, NULL, NULL, &params->lvp, NULL, name); rc = get_property(NULL, NULL, NULL, NULL, NULL, &params->lvp, NULL, name);
} else {
log_error("Invalid lv_create_params parameter");
}
restore_user_env(&e); restore_user_env(&e);
} else
log_error("Invalid lv_create_params parameter");
return rc; return rc;
} }
@ -775,15 +773,14 @@ int lvm_lv_params_set_property(lv_create_params_t params, const char *name,
struct lvm_property_value *prop) struct lvm_property_value *prop)
{ {
int rc = -1; int rc = -1;
struct saved_env e = store_user_env(params->vg->cmd);
if (params && params->magic == LV_CREATE_PARAMS_MAGIC) { if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
struct saved_env e = store_user_env(params->vg->cmd);
rc = set_property(NULL, NULL, NULL, &params->lvp, NULL, name, prop); rc = set_property(NULL, NULL, NULL, &params->lvp, NULL, name, prop);
} else {
log_error("Invalid lv_create_params parameter");
}
restore_user_env(&e); restore_user_env(&e);
} else
log_error("Invalid lv_create_params parameter");
return rc; return rc;
} }