Get rid of non-OCF error codes
Let's put an end to random crashes and vague error messages in pyocf! Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
476573bffa
commit
1c7de189e2
@ -54,10 +54,10 @@ static int _ocf_uuid_set(const struct ocf_volume_uuid *uuid,
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (!uuid->data)
|
if (!uuid->data)
|
||||||
return -EINVAL;
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
if (uuid->size > sizeof(muuid->data))
|
if (uuid->size > sizeof(muuid->data))
|
||||||
return -ENOBUFS;
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
result = env_memcpy(muuid->data, sizeof(muuid->data),
|
result = env_memcpy(muuid->data, sizeof(muuid->data),
|
||||||
uuid->data, uuid->size);
|
uuid->data, uuid->size);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright(c) 2012-2022 Intel Corporation
|
* Copyright(c) 2012-2022 Intel Corporation
|
||||||
|
* Copyright(c) 2024 Huawei Technologies
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -25,19 +26,19 @@ int ocf_ctx_register_volume_type_internal(ocf_ctx_t ctx, uint8_t type_id,
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (!ctx || !properties)
|
if (!ctx || !properties)
|
||||||
return -EINVAL;
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
env_rmutex_lock(&ctx->lock);
|
env_rmutex_lock(&ctx->lock);
|
||||||
|
|
||||||
if (type_id >= OCF_VOLUME_TYPE_MAX || ctx->volume_type[type_id]) {
|
if (type_id >= OCF_VOLUME_TYPE_MAX || ctx->volume_type[type_id]) {
|
||||||
env_rmutex_unlock(&ctx->lock);
|
env_rmutex_unlock(&ctx->lock);
|
||||||
result = -EINVAL;
|
result = -OCF_ERR_INVAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ocf_volume_type_init(&ctx->volume_type[type_id], properties, extended);
|
ocf_volume_type_init(&ctx->volume_type[type_id], properties, extended);
|
||||||
if (!ctx->volume_type[type_id])
|
if (!ctx->volume_type[type_id])
|
||||||
result = -EINVAL;
|
result = -OCF_ERR_INVAL;
|
||||||
|
|
||||||
env_rmutex_unlock(&ctx->lock);
|
env_rmutex_unlock(&ctx->lock);
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ int ocf_ctx_register_volume_type(ocf_ctx_t ctx, uint8_t type_id,
|
|||||||
const struct ocf_volume_properties *properties)
|
const struct ocf_volume_properties *properties)
|
||||||
{
|
{
|
||||||
if (type_id >= OCF_VOLUME_TYPE_MAX_USER)
|
if (type_id >= OCF_VOLUME_TYPE_MAX_USER)
|
||||||
return -EINVAL;
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
return ocf_ctx_register_volume_type_internal(ctx, type_id,
|
return ocf_ctx_register_volume_type_internal(ctx, type_id,
|
||||||
properties, NULL);
|
properties, NULL);
|
||||||
@ -150,7 +151,7 @@ int ocf_ctx_volume_create(ocf_ctx_t ctx, ocf_volume_t *volume,
|
|||||||
|
|
||||||
volume_type = ocf_ctx_get_volume_type(ctx, type_id);
|
volume_type = ocf_ctx_get_volume_type(ctx, type_id);
|
||||||
if (!volume_type)
|
if (!volume_type)
|
||||||
return -EINVAL;
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
return ocf_volume_create(volume, volume_type, uuid);
|
return ocf_volume_create(volume, volume_type, uuid);
|
||||||
}
|
}
|
||||||
@ -188,7 +189,7 @@ int ocf_ctx_create(ocf_ctx_t *ctx, const struct ocf_ctx_config *cfg)
|
|||||||
|
|
||||||
ocf_ctx = env_zalloc(sizeof(*ocf_ctx), ENV_MEM_NORMAL);
|
ocf_ctx = env_zalloc(sizeof(*ocf_ctx), ENV_MEM_NORMAL);
|
||||||
if (!ocf_ctx)
|
if (!ocf_ctx)
|
||||||
return -ENOMEM;
|
return -OCF_ERR_NO_MEM;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&ocf_ctx->caches);
|
INIT_LIST_HEAD(&ocf_ctx->caches);
|
||||||
env_atomic_set(&ocf_ctx->ref_count, 1);
|
env_atomic_set(&ocf_ctx->ref_count, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user