mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-07-26 08:25:31 -04:00
fw: Return 0 on sys_alloc success, -1 on error
It is left to the app to keep track of whether it has had access to the allocated area before.
This commit is contained in:
parent
887883c8db
commit
5a9b77806f
1 changed files with 5 additions and 7 deletions
|
@ -67,20 +67,18 @@ static int storage_get_area(struct partition_table *part_table)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a new area for an app. Returns zero if a new area is
|
// Allocate a new area for an app. Returns zero on success.
|
||||||
// allocated, one if an area already was allocated, and negative
|
|
||||||
// values for errors.
|
|
||||||
int storage_allocate_area(struct partition_table_storage *part_table_storage)
|
int storage_allocate_area(struct partition_table_storage *part_table_storage)
|
||||||
{
|
{
|
||||||
if (part_table_storage == NULL) {
|
if (part_table_storage == NULL) {
|
||||||
return -4;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct partition_table *part_table = &part_table_storage->table;
|
struct partition_table *part_table = &part_table_storage->table;
|
||||||
|
|
||||||
if (storage_get_area(part_table) != -1) {
|
if (storage_get_area(part_table) != -1) {
|
||||||
/* Already has an area */
|
/* Already has an area */
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = get_first_empty(part_table);
|
int index = get_first_empty(part_table);
|
||||||
|
@ -92,7 +90,7 @@ int storage_allocate_area(struct partition_table_storage *part_table_storage)
|
||||||
uint32_t start_address = 0;
|
uint32_t start_address = 0;
|
||||||
|
|
||||||
if (index_to_address(index, &start_address) != 0) {
|
if (index_to_address(index, &start_address) != 0) {
|
||||||
return -3;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate the empty index found
|
// Allocate the empty index found
|
||||||
|
@ -108,7 +106,7 @@ int storage_allocate_area(struct partition_table_storage *part_table_storage)
|
||||||
auth_app_create(&part_table->app_storage[index].auth);
|
auth_app_create(&part_table->app_storage[index].auth);
|
||||||
|
|
||||||
if (part_table_write(part_table_storage) != 0) {
|
if (part_table_write(part_table_storage) != 0) {
|
||||||
return -5;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue