Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add const to string parameters #878

Merged
merged 1 commit into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/hal/interface/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool storageTest();
*
* @return true in case of success, false otherwise.
*/
bool storageStore(char* key, const void* buffer, size_t length);
bool storageStore(const char* key, const void* buffer, size_t length);

/**
* Fetch a buffer from the memory at some key.
Expand All @@ -75,7 +75,7 @@ bool storageStore(char* key, const void* buffer, size_t length);
* receiving buffer, and the length of the data in memory. If the key is not found
* this function returns 0.
*/
size_t storageFetch(char *key, void* buffer, size_t length);
size_t storageFetch(const char *key, void* buffer, size_t length);

/**
* Deletes and entry from the storage.
Expand All @@ -84,4 +84,4 @@ size_t storageFetch(char *key, void* buffer, size_t length);
*
* @return true in case of success. false if the key was not found or if an error occured.
*/
bool storageDelete(char* key);
bool storageDelete(const char* key);
6 changes: 3 additions & 3 deletions src/hal/src/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ bool storageTest()
return pass;
}

bool storageStore(char* key, const void* buffer, size_t length)
bool storageStore(const char* key, const void* buffer, size_t length)
{
if (!isInit) {
return false;
Expand All @@ -163,7 +163,7 @@ bool storageStore(char* key, const void* buffer, size_t length)
return result;
}

size_t storageFetch(char *key, void* buffer, size_t length)
size_t storageFetch(const char *key, void* buffer, size_t length)
{
if (!isInit) {
return 0;
Expand All @@ -178,7 +178,7 @@ size_t storageFetch(char *key, void* buffer, size_t length)
return result;
}

bool storageDelete(char* key)
bool storageDelete(const char* key)
{
if (!isInit) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/interface/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int consolePutcharFromISR(int ch);
* @param str Null terminated string
* @return a nonnegative number on success, or EOF on error.
*/
int consolePuts(char *str);
int consolePuts(const char *str);

/**
* Flush the console buffer
Expand Down
2 changes: 1 addition & 1 deletion src/modules/interface/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef uint16_t logVarId_t;
* @param name Name of the variable
* @return The variable ID or an invalid ID. Use logVarIdIsValid() to check validity.
*/
logVarId_t logGetVarId(char* group, char* name);
logVarId_t logGetVarId(const char* group, const char* name);

/** Check variable ID validity
*
Expand Down
2 changes: 1 addition & 1 deletion src/modules/interface/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef struct paramVarId_s {
* @param name Name of the variable
* @return The variable ID or an invalid ID. Use PARAM_VARID_IS_VALID() to check validity.
*/
paramVarId_t paramGetVarId(char* group, char* name);
paramVarId_t paramGetVarId(const char* group, const char* name);

/** Check variable ID validity
*
Expand Down
2 changes: 1 addition & 1 deletion src/modules/src/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int consolePutcharFromISR(int ch) {
return ch;
}

int consolePuts(char *str)
int consolePuts(const char *str)
{
int ret = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/modules/src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ static void logReset(void)
/* Public API to access log TOC from within the copter */
static logVarId_t invalidVarId = 0xffffu;

logVarId_t logGetVarId(char* group, char* name)
logVarId_t logGetVarId(const char* group, const char* name)
{
int i;
logVarId_t varId = invalidVarId;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/src/param.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static int variableGetIndex(int id)
/* Public API to access param TOC from within the copter */
static paramVarId_t invalidVarId = {0xffffu, 0xffffu};

paramVarId_t paramGetVarId(char* group, char* name)
paramVarId_t paramGetVarId(const char* group, const char* name)
{
int ptr;
int id = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/interface/kve/kve.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@

void kveDefrag(kveMemory_t *kve);

bool kveStore(kveMemory_t *kve, char* key, const void* buffer, size_t length);
bool kveStore(kveMemory_t *kve, const char* key, const void* buffer, size_t length);

size_t kveFetch(kveMemory_t *kve, const char* key, void* buffer, size_t bufferLength);

bool kveDelete(kveMemory_t *kve, char* key);
bool kveDelete(kveMemory_t *kve, const char* key);

void kveFormat(kveMemory_t *kve);

Expand Down
4 changes: 2 additions & 2 deletions src/utils/src/kve/kve.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void kveDefrag(kveMemory_t *kve) {
}
}

bool kveStore(kveMemory_t *kve, char* key, const void* buffer, size_t length) {
bool kveStore(kveMemory_t *kve, const char* key, const void* buffer, size_t length) {
size_t itemAddress;

// Search if the key is already present in the table
Expand Down Expand Up @@ -127,7 +127,7 @@ size_t kveFetch(kveMemory_t *kve, const char* key, void* buffer, size_t bufferLe
return 0;
}

bool kveDelete(kveMemory_t *kve, char* key) {
bool kveDelete(kveMemory_t *kve, const char* key) {
size_t itemAddress = kveStorageFindItemByKey(kve, FIRST_ITEM_ADDRESS, key);

if (KVE_STORAGE_IS_VALID(itemAddress)) {
Expand Down