Merge pull request #298 from Ostrokrzew/ptr_to_arr

Core name - pointer to array change
This commit is contained in:
Michal Rakowski 2019-09-30 16:06:27 +02:00 committed by GitHub
commit c65a25fff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 22 deletions

View File

@ -22,7 +22,7 @@ struct ocf_mngt_core_config {
/**
* @brief OCF core name
*/
const char *name;
char name[OCF_CORE_NAME_SIZE];
/**
* @brief OCF core volume UUID

View File

@ -476,7 +476,6 @@ static void ocf_mngt_cache_add_core_finish(ocf_pipeline_t pipeline,
out:
context->cmpl(cache, core, context->priv, error);
env_vfree(context->cfg.name);
env_vfree(context->cfg.uuid.data);
ocf_pipeline_destroy(context->pipeline);
}
@ -509,7 +508,6 @@ void ocf_mngt_cache_add_core(ocf_cache_t cache,
{
struct ocf_cache_add_core_context *context;
ocf_pipeline_t pipeline;
char *name;
void *data;
int result;
@ -518,7 +516,7 @@ void ocf_mngt_cache_add_core(ocf_cache_t cache,
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, NULL, priv, -OCF_ERR_INVAL);
if (!cfg->name)
if (!env_strnlen(cfg->name, OCF_CORE_NAME_SIZE))
OCF_CMPL_RET(cache, NULL, priv, -OCF_ERR_INVAL);
result = ocf_pipeline_create(&pipeline, cache, cfg->try_add ?
@ -535,23 +533,10 @@ void ocf_mngt_cache_add_core(ocf_cache_t cache,
context->cache = cache;
context->cfg = *cfg;
name = env_vmalloc(OCF_CORE_NAME_SIZE);
if (!name) {
result = -OCF_ERR_NO_MEM;
goto err_pipeline;
}
result = env_strncpy(name, OCF_CORE_NAME_SIZE,
cfg->name, OCF_CORE_NAME_SIZE);
if (result)
goto err_name;
context->cfg.name = name;
data = env_vmalloc(cfg->uuid.size);
if (!data) {
result = -OCF_ERR_NO_MEM;
goto err_name;
goto err_pipeline;
}
result = env_memcpy(data, cfg->uuid.size, cfg->uuid.data,
@ -565,8 +550,6 @@ void ocf_mngt_cache_add_core(ocf_cache_t cache,
err_uuid:
env_vfree(data);
err_name:
env_vfree(context->cfg.name);
err_pipeline:
ocf_pipeline_destroy(context->pipeline);
OCF_CMPL_RET(cache, NULL, priv, result);

View File

@ -13,6 +13,7 @@ from ctypes import (
c_uint16,
c_uint32,
c_uint64,
c_char,
c_char_p,
c_bool,
cast,
@ -37,8 +38,9 @@ class UserMetadata(Structure):
class CoreConfig(Structure):
MAX_CORE_NAME_SIZE = 32
_fields_ = [
("_name", c_char_p),
("_name", c_char * MAX_CORE_NAME_SIZE),
("_uuid", Uuid),
("_volume_type", c_uint8),
("_try_add", c_bool),
@ -70,7 +72,7 @@ class Core:
),
_size=len(self.device_name) + 1,
),
_name=cast(create_string_buffer(name.encode("ascii")), c_char_p),
_name=name.encode("ascii"),
_volume_type=self.device.type_id,
_try_add=try_add,
_seq_cutoff_threshold=seq_cutoff_threshold,