Skip to content

Commit 7c2a1dd

Browse files
committed
add underscores before all private functions
1 parent 78ddf1c commit 7c2a1dd

5 files changed

Lines changed: 56 additions & 56 deletions

File tree

middleware/include/eeprom_alloc.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* @retval EEPROM_ERROR If EEPROM read operation fails.
3333
*/
34-
eeprom_status_t init_alloc_table(eeprom_directory_t *directory);
34+
eeprom_status_t _init_alloc_table(eeprom_directory_t *directory);
3535

3636
/**
3737
* @brief Print the allocation table in a human-readable format.
@@ -42,7 +42,7 @@ eeprom_status_t init_alloc_table(eeprom_directory_t *directory);
4242
*
4343
* @param directory Pointer to the initialized directory structure.
4444
*/
45-
void print_alloc_table(eeprom_directory_t *directory);
45+
void _print_alloc_table(eeprom_directory_t *directory);
4646

4747
/**
4848
* @brief Allocate a single block from the EEPROM.
@@ -57,7 +57,7 @@ void print_alloc_table(eeprom_directory_t *directory);
5757
*
5858
* @retval BLOCK_COUNT If no free blocks are available or EEPROM update fails.
5959
*/
60-
uint16_t alloc_block(eeprom_directory_t *directory);
60+
uint16_t _alloc_block(eeprom_directory_t *directory);
6161

6262
/**
6363
* @brief Free one or more blocks in the EEPROM.
@@ -70,7 +70,7 @@ uint16_t alloc_block(eeprom_directory_t *directory);
7070
* @param ids Array of block IDs to free.
7171
* @param size Number of block IDs in the array.
7272
*/
73-
void free_block(eeprom_directory_t *directory, uint16_t *ids, uint8_t size);
73+
void _free_block(eeprom_directory_t *directory, uint16_t *ids, uint8_t size);
7474

7575
/**
7676
* @brief Check if a block is allocated.
@@ -83,6 +83,6 @@ void free_block(eeprom_directory_t *directory, uint16_t *ids, uint8_t size);
8383
*
8484
* @return int Returns 1 if the block is allocated, 0 if it is free.
8585
*/
86-
int is_allocated(eeprom_directory_t *directory, uint16_t id);
86+
int _is_allocated(eeprom_directory_t *directory, uint16_t id);
8787

8888
#endif

middleware/include/eeprom_storage.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @retval EEPROM_ERROR_ALLOCATION If memory allocation fails.
3232
* @retval EEPROM_ERROR If EEPROM read operation fails.
3333
*/
34-
eeprom_status_t init_storage(eeprom_directory_t *directory);
34+
eeprom_status_t _init_storage(eeprom_directory_t *directory);
3535

3636
/**
3737
* @brief Retrieve data from EEPROM using block IDs.
@@ -53,7 +53,7 @@ eeprom_status_t init_storage(eeprom_directory_t *directory);
5353
* @retval EEPROM_ERROR_NOT_FOUND If any block ID is not allocated.
5454
* @retval EEPROM_ERROR If EEPROM read operation fails.
5555
*/
56-
eeprom_status_t get_data(eeprom_directory_t *directory, const uint16_t *ids,
56+
eeprom_status_t _get_data(eeprom_directory_t *directory, const uint16_t *ids,
5757
uint8_t **out, uint16_t *out_size);
5858

5959
/**
@@ -74,7 +74,7 @@ eeprom_status_t get_data(eeprom_directory_t *directory, const uint16_t *ids,
7474
* @retval EEPROM_ERROR_ALLOCATION If memory allocation for block buffer fails.
7575
* @retval EEPROM_ERROR If EEPROM write operation fails.
7676
*/
77-
eeprom_status_t put_data(eeprom_directory_t *directory, const uint16_t *ids,
77+
eeprom_status_t _put_data(eeprom_directory_t *directory, const uint16_t *ids,
7878
uint8_t *value, uint16_t value_size);
7979

8080
/**
@@ -88,6 +88,6 @@ eeprom_status_t put_data(eeprom_directory_t *directory, const uint16_t *ids,
8888
*
8989
* @return eeprom_status_t Returns EEPROM_OK on success.
9090
*/
91-
eeprom_status_t delete_data(eeprom_directory_t *directory, uint16_t *ids);
91+
eeprom_status_t _delete_data(eeprom_directory_t *directory, uint16_t *ids);
9292

9393
#endif

middleware/src/eeprom_alloc.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
#define bit_index(n) ((n) % 8)
55
#define nth_bit_mask(n) (1 << (n))
66

7-
static int get_alloc_table(uint8_t *table, uint16_t id)
7+
static int _get_alloc_table(uint8_t *table, uint16_t id)
88
{
99
return (table[byte_index(id)] >> bit_index(id)) & 1;
1010
}
1111

12-
static void put_alloc_table(uint8_t *table, uint16_t id, uint8_t val)
12+
static void _put_alloc_table(uint8_t *table, uint16_t id, uint8_t val)
1313
{
1414
uint8_t bit_mask = nth_bit_mask(bit_index(id));
1515

@@ -21,7 +21,7 @@ static void put_alloc_table(uint8_t *table, uint16_t id, uint8_t val)
2121
}
2222
}
2323

24-
static eeprom_status_t update_eeprom_alloc_table(eeprom_directory_t *directory,
24+
static eeprom_status_t _update_eeprom_alloc_table(eeprom_directory_t *directory,
2525
uint16_t id)
2626
{
2727
uint16_t data_index = byte_index(id);
@@ -32,19 +32,19 @@ static eeprom_status_t update_eeprom_alloc_table(eeprom_directory_t *directory,
3232
return m24c32_write(device, addr, data, 1);
3333
}
3434

35-
eeprom_status_t init_alloc_table(eeprom_directory_t *directory)
35+
eeprom_status_t _init_alloc_table(eeprom_directory_t *directory)
3636
{
3737
m24c32_t *device = directory->device;
3838

3939
return m24c32_read(device, ALLOC_TABLE_BEGIN, directory->alloc_table,
4040
ALLOC_TABLE_SIZE);
4141
}
4242

43-
void print_alloc_table(eeprom_directory_t *directory)
43+
void _print_alloc_table(eeprom_directory_t *directory)
4444
{
4545
uint8_t *alloc_table = directory->alloc_table;
4646
for (int id = 0; id < BLOCK_COUNT; id++) {
47-
putchar(get_alloc_table(alloc_table, id) ? '1' : '0');
47+
putchar(_get_alloc_table(alloc_table, id) ? '1' : '0');
4848

4949
if ((id + 1) % 64 == 0) {
5050
putchar('\n');
@@ -55,18 +55,18 @@ void print_alloc_table(eeprom_directory_t *directory)
5555
putchar('\n');
5656
}
5757

58-
uint16_t alloc_block(eeprom_directory_t *directory)
58+
uint16_t _alloc_block(eeprom_directory_t *directory)
5959
{
6060
uint8_t *alloc_table = directory->alloc_table;
6161

6262
for (uint16_t id = 0; id < BLOCK_COUNT; id++) {
63-
if (get_alloc_table(alloc_table, id) == 0) {
64-
put_alloc_table(alloc_table, id, 1);
63+
if (_get_alloc_table(alloc_table, id) == 0) {
64+
_put_alloc_table(alloc_table, id, 1);
6565
eeprom_status_t ret =
66-
update_eeprom_alloc_table(directory, id);
66+
_update_eeprom_alloc_table(directory, id);
6767
if (ret != EEPROM_OK) {
6868
printf("ERROR: failed to update eeprom alloc table.\n");
69-
put_alloc_table(alloc_table, id, 0);
69+
_put_alloc_table(alloc_table, id, 0);
7070
return BLOCK_COUNT;
7171
}
7272
return id;
@@ -75,23 +75,23 @@ uint16_t alloc_block(eeprom_directory_t *directory)
7575
return BLOCK_COUNT;
7676
}
7777

78-
void free_block(eeprom_directory_t *directory, uint16_t *ids, uint8_t size)
78+
void _free_block(eeprom_directory_t *directory, uint16_t *ids, uint8_t size)
7979
{
8080
uint8_t *alloc_table = directory->alloc_table;
8181

8282
for (int i = 0; i < size; i++) {
8383
uint16_t id = ids[i];
84-
put_alloc_table(alloc_table, id, 0);
85-
eeprom_status_t ret = update_eeprom_alloc_table(directory, id);
84+
_put_alloc_table(alloc_table, id, 0);
85+
eeprom_status_t ret = _update_eeprom_alloc_table(directory, id);
8686
if (ret != EEPROM_OK) {
8787
printf("ERROR: failed to update eeprom allo table.\n");
8888
}
8989
}
9090
}
9191

92-
int is_allocated(eeprom_directory_t *directory, uint16_t id)
92+
int _is_allocated(eeprom_directory_t *directory, uint16_t id)
9393
{
9494
uint8_t *alloc_table = directory->alloc_table;
9595

96-
return get_alloc_table(alloc_table, id);
96+
return _get_alloc_table(alloc_table, id);
9797
}

middleware/src/eeprom_directory.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "eeprom_directory.h"
22

3-
static uint16_t *get_ids(eeprom_directory_t *directory, const uint8_t *key)
3+
static uint16_t *_get_ids(eeprom_directory_t *directory, const uint8_t *key)
44
{
55
directory_key_map_t *key_map = directory->key_map;
66

@@ -13,7 +13,7 @@ static uint16_t *get_ids(eeprom_directory_t *directory, const uint8_t *key)
1313
return NULL;
1414
}
1515

16-
static eeprom_status_t set_key(eeprom_directory_t *directory,
16+
static eeprom_status_t _set_key(eeprom_directory_t *directory,
1717
const uint8_t *key, uint16_t *ids)
1818
{
1919
m24c32_t *device = directory->device;
@@ -33,7 +33,7 @@ static eeprom_status_t set_key(eeprom_directory_t *directory,
3333
return EEPROM_ERROR_ALLOCATION;
3434
}
3535

36-
static eeprom_status_t delete_key(eeprom_directory_t *directory,
36+
static eeprom_status_t _delete_key(eeprom_directory_t *directory,
3737
const uint8_t *key)
3838
{
3939
m24c32_t *device = directory->device;
@@ -61,11 +61,11 @@ eeprom_status_t directory_init(m24c32_t *device, eeprom_directory_t *directory)
6161

6262
directory->device = device;
6363
eeprom_status_t res;
64-
res = init_alloc_table(directory);
64+
res = _init_alloc_table(directory);
6565
if (res != EEPROM_OK) {
6666
return res;
6767
}
68-
res = init_storage(directory);
68+
res = _init_storage(directory);
6969
if (res != EEPROM_OK) {
7070
return res;
7171
}
@@ -81,12 +81,12 @@ eeprom_status_t get_directory_value(eeprom_directory_t *directory,
8181
return EEPROM_ERROR_NULL_POINTER;
8282
}
8383

84-
uint16_t *ids = get_ids(directory, key);
84+
uint16_t *ids = _get_ids(directory, key);
8585
if (ids == NULL) {
8686
return EEPROM_ERROR_NOT_FOUND;
8787
}
8888

89-
return get_data(directory, ids, out, out_size);
89+
return _get_data(directory, ids, out, out_size);
9090
}
9191

9292
eeprom_status_t set_directory_value(eeprom_directory_t *directory,
@@ -100,7 +100,7 @@ eeprom_status_t set_directory_value(eeprom_directory_t *directory,
100100
return EEPROM_ERROR;
101101
}
102102

103-
uint16_t *existing_ids = get_ids(directory, key);
103+
uint16_t *existing_ids = _get_ids(directory, key);
104104

105105
// If key already exists, delete it first
106106
if (existing_ids != NULL) {
@@ -122,11 +122,11 @@ eeprom_status_t set_directory_value(eeprom_directory_t *directory,
122122
}
123123

124124
for (int block_idx = 0; block_idx < block_count; block_idx++) {
125-
uint16_t id = alloc_block(directory);
125+
uint16_t id = _alloc_block(directory);
126126
if (id == BLOCK_COUNT) {
127127
// Free already allocated blocks on failure
128128
for (int j = 0; j < block_idx; j++) {
129-
free_block(directory, &ids[j], 1);
129+
_free_block(directory, &ids[j], 1);
130130
}
131131
free(ids);
132132
return EEPROM_ERROR_ALLOCATION;
@@ -138,19 +138,19 @@ eeprom_status_t set_directory_value(eeprom_directory_t *directory,
138138
}
139139

140140
eeprom_status_t res;
141-
res = set_key(directory, key, ids);
141+
res = _set_key(directory, key, ids);
142142
if (res != EEPROM_OK) {
143143
// Free allocated blocks on failure
144-
free_block(directory, ids, block_count);
144+
_free_block(directory, ids, block_count);
145145
free(ids);
146146
return res;
147147
}
148148

149-
res = put_data(directory, ids, value, value_size);
149+
res = _put_data(directory, ids, value, value_size);
150150
if (res != EEPROM_OK) {
151151
// Free allocated blocks and remove key on failure
152-
free_block(directory, ids, block_count);
153-
delete_key(directory, key);
152+
_free_block(directory, ids, block_count);
153+
_delete_key(directory, key);
154154
free(ids);
155155
return res;
156156
}
@@ -166,15 +166,15 @@ eeprom_status_t delete_directory_value(eeprom_directory_t *directory,
166166
return EEPROM_ERROR_NULL_POINTER;
167167
}
168168

169-
uint16_t *ids = get_ids(directory, key);
169+
uint16_t *ids = _get_ids(directory, key);
170170
if (ids == NULL) {
171171
return EEPROM_ERROR_NOT_FOUND;
172172
}
173173

174174
eeprom_status_t res;
175-
res = delete_data(directory, ids);
175+
res = _delete_data(directory, ids);
176176
if (res != EEPROM_OK) {
177177
return res;
178178
}
179-
return delete_key(directory, key);
179+
return _delete_key(directory, key);
180180
}

middleware/src/eeprom_storage.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "eeprom_storage.h"
22
#include <string.h>
33

4-
static uint8_t get_id_count(const uint16_t *ids)
4+
static uint8_t _get_id_count(const uint16_t *ids)
55
{
66
uint8_t count = 0;
77

@@ -14,12 +14,12 @@ static uint8_t get_id_count(const uint16_t *ids)
1414
return count;
1515
}
1616

17-
static uint16_t get_addr_for_data(const uint16_t id)
17+
static uint16_t _get_addr_for_data(const uint16_t id)
1818
{
1919
return DATA_SPACE_BEGIN + id * BLOCK_SIZE;
2020
}
2121

22-
eeprom_status_t init_storage(eeprom_directory_t *directory)
22+
eeprom_status_t _init_storage(eeprom_directory_t *directory)
2323
{
2424
m24c32_t *device = directory->device;
2525
directory_key_map_t *key_map = directory->key_map;
@@ -52,10 +52,10 @@ eeprom_status_t init_storage(eeprom_directory_t *directory)
5252
return EEPROM_OK;
5353
}
5454

55-
eeprom_status_t get_data(eeprom_directory_t *directory, const uint16_t *ids,
55+
eeprom_status_t _get_data(eeprom_directory_t *directory, const uint16_t *ids,
5656
uint8_t **out, uint16_t *out_size)
5757
{
58-
uint8_t id_count = get_id_count(ids);
58+
uint8_t id_count = _get_id_count(ids);
5959
*out_size = BLOCK_SIZE * id_count;
6060

6161
// Free existing buffer if provided
@@ -72,13 +72,13 @@ eeprom_status_t get_data(eeprom_directory_t *directory, const uint16_t *ids,
7272

7373
for (int i = 0; i < id_count; i++) {
7474
uint16_t id = ids[i];
75-
if (!is_allocated(directory, id)) {
75+
if (!_is_allocated(directory, id)) {
7676
free(*out);
7777
*out = NULL;
7878
return EEPROM_ERROR_NOT_FOUND;
7979
}
8080

81-
uint16_t addr = get_addr_for_data(id);
81+
uint16_t addr = _get_addr_for_data(id);
8282
uint8_t *data_ptr = *out + BLOCK_SIZE * i;
8383
eeprom_status_t res;
8484

@@ -93,18 +93,18 @@ eeprom_status_t get_data(eeprom_directory_t *directory, const uint16_t *ids,
9393
return EEPROM_OK;
9494
}
9595

96-
eeprom_status_t put_data(eeprom_directory_t *directory, const uint16_t *ids,
96+
eeprom_status_t _put_data(eeprom_directory_t *directory, const uint16_t *ids,
9797
uint8_t *value, uint16_t value_size)
9898
{
99-
uint8_t id_count = get_id_count(ids);
99+
uint8_t id_count = _get_id_count(ids);
100100
uint8_t *block_buffer = malloc(BLOCK_SIZE);
101101
if (block_buffer == NULL) {
102102
return EEPROM_ERROR_ALLOCATION;
103103
}
104104

105105
for (int i = 0; i < id_count; i++) {
106106
uint16_t id = ids[i];
107-
uint16_t addr = get_addr_for_data(id);
107+
uint16_t addr = _get_addr_for_data(id);
108108

109109
// Calculate how many bytes to copy for this block
110110
uint16_t offset = i * BLOCK_SIZE;
@@ -134,10 +134,10 @@ eeprom_status_t put_data(eeprom_directory_t *directory, const uint16_t *ids,
134134
return EEPROM_OK;
135135
}
136136

137-
eeprom_status_t delete_data(eeprom_directory_t *directory, uint16_t *ids)
137+
eeprom_status_t _delete_data(eeprom_directory_t *directory, uint16_t *ids)
138138
{
139-
uint8_t id_count = get_id_count(ids);
139+
uint8_t id_count = _get_id_count(ids);
140140

141-
free_block(directory, ids, id_count);
141+
_free_block(directory, ids, id_count);
142142
return EEPROM_OK;
143143
}

0 commit comments

Comments
 (0)