Commit b43e98b4 authored by Tristan Gingold's avatar Tristan Gingold Committed by Federico Vaga

sw:lib: constify function arguments and return value

For these function there is not need, actually is dangerous, to
touch the given char pointer. Make it constant to avoid mistakes.
Signed-off-by: Tristan Gingold's avatarTristan Gingold <tristan.gingold@cern.ch>
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent bb80c5b3
......@@ -36,7 +36,7 @@ const unsigned int trtl_default_timeout_ms = 1000;
/**
* Mock Turtle error code strings
*/
static char *trtl_error_str[] = {
static const char * const trtl_error_str[] = {
"Cannot parse data from sysfs attribute",
"Invalid slot",
"Operation not yet implemented",
......@@ -92,7 +92,7 @@ static int trtl_sysfs_write(char *path, void *buf, size_t len);
* @param[in] err error code. Typically 'errno' variable
* @return a message error. No need to free the string.
*/
char *trtl_strerror(int err)
const char *trtl_strerror(int err)
{
if (err < ETRTL_INVAL_PARSE || err > __ETRTL_MAX)
return strerror(err);
......@@ -575,7 +575,7 @@ int trtl_cpu_reset_set(struct trtl_dev *trtl, uint32_t mask)
*/
int trtl_cpu_load_application_raw(struct trtl_dev *trtl,
unsigned int index,
void *code, size_t length,
const void *code, size_t length,
unsigned int offset)
{
struct trtl_desc *wdesc = (struct trtl_desc *)trtl;
......@@ -658,7 +658,7 @@ int trtl_cpu_dump_application_raw(struct trtl_dev *trtl,
*/
int trtl_cpu_load_application_file(struct trtl_dev *trtl,
unsigned int index,
char *path)
const char *path)
{
int i, len;
void *code;
......@@ -709,7 +709,7 @@ int trtl_cpu_load_application_file(struct trtl_dev *trtl,
*/
int trtl_cpu_dump_application_file(struct trtl_dev *trtl,
unsigned int index,
char *path)
const char *path)
{
int i = 0;
uint8_t code[4096];
......
......@@ -101,7 +101,7 @@ const struct trtl_config_rom *trtl_config_get(struct trtl_dev *trtl);
extern void trtl_print_header(struct trtl_msg *msg);
extern void trtl_print_payload(struct trtl_msg *msg);
extern void trtl_print_message(struct trtl_msg *msg);
extern char *trtl_strerror(int err);
extern const char *trtl_strerror(int err);
/**@}*/
/**
......@@ -111,18 +111,18 @@ extern char *trtl_strerror(int err);
*/
extern int trtl_cpu_load_application_raw(struct trtl_dev *trtl,
unsigned int index,
void *code, size_t length,
const void *code, size_t length,
unsigned int offset);
extern int trtl_cpu_load_application_file(struct trtl_dev *trtl,
unsigned int index,
char *path);
const char *path);
extern int trtl_cpu_dump_application_raw(struct trtl_dev *trtl,
unsigned int index,
void *code, size_t length,
unsigned int offset);
extern int trtl_cpu_dump_application_file(struct trtl_dev *trtl,
unsigned int index,
char *path);
const char *path);
extern int trtl_cpu_reset_set(struct trtl_dev *trtl, uint32_t mask);
extern int trtl_cpu_reset_get(struct trtl_dev *trtl, uint32_t *mask);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment