Skip to content

Commit

Permalink
Fix and add error messages
Browse files Browse the repository at this point in the history
Fix two error messages and add some new ones.

Signed-off-by: Lukasz Dorau <[email protected]>
  • Loading branch information
ldorau committed Nov 14, 2024
1 parent b260d82 commit efef7d0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
32 changes: 23 additions & 9 deletions src/provider/provider_file_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ static umf_result_t file_alloc(void *provider, size_t size, size_t alignment,
addr, alloc_offset_fd);
}

LOG_DEBUG("inserted a value to the file descriptor offset map (addr=%p, "
"offset=%zu)",
addr, alloc_offset_fd);

*resultPtr = addr;

return UMF_RESULT_SUCCESS;
Expand Down Expand Up @@ -552,23 +556,31 @@ static umf_result_t file_allocation_split(void *provider, void *ptr,

void *value = critnib_get(file_provider->fd_offset_map, (uintptr_t)ptr);
if (value == NULL) {
LOG_ERR("file_allocation_split(): getting a value from the file "
"descriptor offset map failed (addr=%p)",
LOG_ERR("getting a value from the file descriptor offset map failed "
"(addr=%p)",
ptr);
return UMF_RESULT_ERROR_UNKNOWN;
}

LOG_ERR("splitting the value from the file descriptor offset map (addr=%p) "
"from size %zu to %zu + %zu",
ptr, totalSize, firstSize, totalSize - firstSize);

uintptr_t new_key = (uintptr_t)ptr + firstSize;
void *new_value = (void *)((uintptr_t)value + firstSize);
int ret = critnib_insert(file_provider->fd_offset_map, new_key, new_value,
0 /* update */);
if (ret) {
LOG_ERR("file_allocation_split(): inserting a value to the file "
"descriptor offset map failed (addr=%p, offset=%zu)",
LOG_ERR("inserting a value to the file descriptor offset map failed "
"(addr=%p, offset=%zu)",
(void *)new_key, (size_t)new_value - 1);
return UMF_RESULT_ERROR_UNKNOWN;
}

LOG_DEBUG("inserted a value to the file descriptor offset map (addr=%p, "
"offset=%zu)",
(void *)new_key, (size_t)new_value - 1);

return UMF_RESULT_SUCCESS;
}

Expand All @@ -586,12 +598,16 @@ static umf_result_t file_allocation_merge(void *provider, void *lowPtr,
void *value =
critnib_remove(file_provider->fd_offset_map, (uintptr_t)highPtr);
if (value == NULL) {
LOG_ERR("file_allocation_merge(): removing a value from the file "
"descriptor offset map failed (addr=%p)",
LOG_ERR("removing a value from the file descriptor offset map failed "
"(addr=%p)",
highPtr);
return UMF_RESULT_ERROR_UNKNOWN;
}

LOG_DEBUG("removed a value from the file descriptor offset map (addr=%p) - "
"merged with %p",
highPtr, lowPtr);

return UMF_RESULT_SUCCESS;
}

Expand Down Expand Up @@ -633,9 +649,7 @@ static umf_result_t file_get_ipc_handle(void *provider, const void *ptr,

void *value = critnib_get(file_provider->fd_offset_map, (uintptr_t)ptr);
if (value == NULL) {
LOG_ERR("file_get_ipc_handle(): getting a value from the IPC cache "
"failed (addr=%p)",
ptr);
LOG_ERR("getting a value from the IPC cache failed (addr=%p)", ptr);
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
}

Expand Down
4 changes: 1 addition & 3 deletions src/provider/provider_os_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,9 +1221,7 @@ static umf_result_t os_get_ipc_handle(void *provider, const void *ptr,

void *value = critnib_get(os_provider->fd_offset_map, (uintptr_t)ptr);
if (value == NULL) {
LOG_ERR("os_get_ipc_handle(): getting a value from the IPC cache "
"failed (addr=%p)",
ptr);
LOG_ERR("getting a value from the IPC cache failed (addr=%p)", ptr);
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
}

Expand Down

0 comments on commit efef7d0

Please sign in to comment.