Commit 9d475254 authored by Hartmut Knaack's avatar Hartmut Knaack Committed by Jonathan Cameron

tools:iio:iio_utils: pass strings as const

Mark strings, which are not supposed to be changed (basedir, filename,
value), as const in function parameters.
Signed-off-by: default avatarHartmut Knaack <knaack.h@gmx.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent e06e3d71
......@@ -634,7 +634,8 @@ int find_type_by_name(const char *name, const char *type)
return ret;
}
static int _write_sysfs_int(char *filename, char *basedir, int val, int verify)
static int _write_sysfs_int(const char *filename, const char *basedir, int val,
int verify)
{
int ret = 0;
FILE *sysfsfp;
......@@ -707,7 +708,7 @@ static int _write_sysfs_int(char *filename, char *basedir, int val, int verify)
*
* Returns a value >= 0 on success, otherwise a negative error code.
**/
int write_sysfs_int(char *filename, char *basedir, int val)
int write_sysfs_int(const char *filename, const char *basedir, int val)
{
return _write_sysfs_int(filename, basedir, val, 0);
}
......@@ -721,13 +722,14 @@ int write_sysfs_int(char *filename, char *basedir, int val)
*
* Returns a value >= 0 on success, otherwise a negative error code.
**/
int write_sysfs_int_and_verify(char *filename, char *basedir, int val)
int write_sysfs_int_and_verify(const char *filename, const char *basedir,
int val)
{
return _write_sysfs_int(filename, basedir, val, 1);
}
static int _write_sysfs_string(char *filename, char *basedir, char *val,
int verify)
static int _write_sysfs_string(const char *filename, const char *basedir,
const char *val, int verify)
{
int ret = 0;
FILE *sysfsfp;
......@@ -805,7 +807,8 @@ static int _write_sysfs_string(char *filename, char *basedir, char *val,
*
* Returns a value >= 0 on success, otherwise a negative error code.
**/
int write_sysfs_string_and_verify(char *filename, char *basedir, char *val)
int write_sysfs_string_and_verify(const char *filename, const char *basedir,
const char *val)
{
return _write_sysfs_string(filename, basedir, val, 1);
}
......@@ -818,7 +821,8 @@ int write_sysfs_string_and_verify(char *filename, char *basedir, char *val)
*
* Returns a value >= 0 on success, otherwise a negative error code.
**/
int write_sysfs_string(char *filename, char *basedir, char *val)
int write_sysfs_string(const char *filename, const char *basedir,
const char *val)
{
return _write_sysfs_string(filename, basedir, val, 0);
}
......@@ -831,7 +835,7 @@ int write_sysfs_string(char *filename, char *basedir, char *val)
* Returns the read integer value >= 0 on success, otherwise a negative error
* code.
**/
int read_sysfs_posint(char *filename, char *basedir)
int read_sysfs_posint(const char *filename, const char *basedir)
{
int ret;
FILE *sysfsfp;
......@@ -875,7 +879,7 @@ int read_sysfs_posint(char *filename, char *basedir)
*
* Returns a value >= 0 on success, otherwise a negative error code.
**/
int read_sysfs_float(char *filename, char *basedir, float *val)
int read_sysfs_float(const char *filename, const char *basedir, float *val)
{
int ret = 0;
FILE *sysfsfp;
......
......@@ -63,12 +63,15 @@ void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt);
int build_channel_array(const char *device_dir,
struct iio_channel_info **ci_array, int *counter);
int find_type_by_name(const char *name, const char *type);
int write_sysfs_int(char *filename, char *basedir, int val);
int write_sysfs_int_and_verify(char *filename, char *basedir, int val);
int write_sysfs_string_and_verify(char *filename, char *basedir, char *val);
int write_sysfs_string(char *filename, char *basedir, char *val);
int read_sysfs_posint(char *filename, char *basedir);
int read_sysfs_float(char *filename, char *basedir, float *val);
int write_sysfs_int(const char *filename, const char *basedir, int val);
int write_sysfs_int_and_verify(const char *filename, const char *basedir,
int val);
int write_sysfs_string_and_verify(const char *filename, const char *basedir,
const char *val);
int write_sysfs_string(const char *filename, const char *basedir,
const char *val);
int read_sysfs_posint(const char *filename, const char *basedir);
int read_sysfs_float(const char *filename, const char *basedir, float *val);
int read_sysfs_string(const char *filename, const char *basedir, char *str);
#endif /* _IIO_UTILS_H_ */
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