diff options
author | Hartmut Knaack <knaack.h@gmx.de> | 2015-05-31 08:40:36 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-06-01 03:40:26 -0400 |
commit | 9d4752544d17a10a40be5fc5ef68edcae5363599 (patch) | |
tree | 16730c7cb8cd89c1d19d0635e496e5977a93baa9 /tools/iio | |
parent | e06e3d7112f2ec5494d2d934a8641a53885003ee (diff) |
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: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio')
-rw-r--r-- | tools/iio/iio_utils.c | 22 | ||||
-rw-r--r-- | tools/iio/iio_utils.h | 15 |
2 files changed, 22 insertions, 15 deletions
diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index dfee1a3f3f63..ec9ab7f9ae4c 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c | |||
@@ -634,7 +634,8 @@ error_close_dir: | |||
634 | return ret; | 634 | return ret; |
635 | } | 635 | } |
636 | 636 | ||
637 | static int _write_sysfs_int(char *filename, char *basedir, int val, int verify) | 637 | static int _write_sysfs_int(const char *filename, const char *basedir, int val, |
638 | int verify) | ||
638 | { | 639 | { |
639 | int ret = 0; | 640 | int ret = 0; |
640 | FILE *sysfsfp; | 641 | FILE *sysfsfp; |
@@ -707,7 +708,7 @@ error_free: | |||
707 | * | 708 | * |
708 | * Returns a value >= 0 on success, otherwise a negative error code. | 709 | * Returns a value >= 0 on success, otherwise a negative error code. |
709 | **/ | 710 | **/ |
710 | int write_sysfs_int(char *filename, char *basedir, int val) | 711 | int write_sysfs_int(const char *filename, const char *basedir, int val) |
711 | { | 712 | { |
712 | return _write_sysfs_int(filename, basedir, val, 0); | 713 | return _write_sysfs_int(filename, basedir, val, 0); |
713 | } | 714 | } |
@@ -721,13 +722,14 @@ int write_sysfs_int(char *filename, char *basedir, int val) | |||
721 | * | 722 | * |
722 | * Returns a value >= 0 on success, otherwise a negative error code. | 723 | * Returns a value >= 0 on success, otherwise a negative error code. |
723 | **/ | 724 | **/ |
724 | int write_sysfs_int_and_verify(char *filename, char *basedir, int val) | 725 | int write_sysfs_int_and_verify(const char *filename, const char *basedir, |
726 | int val) | ||
725 | { | 727 | { |
726 | return _write_sysfs_int(filename, basedir, val, 1); | 728 | return _write_sysfs_int(filename, basedir, val, 1); |
727 | } | 729 | } |
728 | 730 | ||
729 | static int _write_sysfs_string(char *filename, char *basedir, char *val, | 731 | static int _write_sysfs_string(const char *filename, const char *basedir, |
730 | int verify) | 732 | const char *val, int verify) |
731 | { | 733 | { |
732 | int ret = 0; | 734 | int ret = 0; |
733 | FILE *sysfsfp; | 735 | FILE *sysfsfp; |
@@ -805,7 +807,8 @@ error_free: | |||
805 | * | 807 | * |
806 | * Returns a value >= 0 on success, otherwise a negative error code. | 808 | * Returns a value >= 0 on success, otherwise a negative error code. |
807 | **/ | 809 | **/ |
808 | int write_sysfs_string_and_verify(char *filename, char *basedir, char *val) | 810 | int write_sysfs_string_and_verify(const char *filename, const char *basedir, |
811 | const char *val) | ||
809 | { | 812 | { |
810 | return _write_sysfs_string(filename, basedir, val, 1); | 813 | return _write_sysfs_string(filename, basedir, val, 1); |
811 | } | 814 | } |
@@ -818,7 +821,8 @@ int write_sysfs_string_and_verify(char *filename, char *basedir, char *val) | |||
818 | * | 821 | * |
819 | * Returns a value >= 0 on success, otherwise a negative error code. | 822 | * Returns a value >= 0 on success, otherwise a negative error code. |
820 | **/ | 823 | **/ |
821 | int write_sysfs_string(char *filename, char *basedir, char *val) | 824 | int write_sysfs_string(const char *filename, const char *basedir, |
825 | const char *val) | ||
822 | { | 826 | { |
823 | return _write_sysfs_string(filename, basedir, val, 0); | 827 | return _write_sysfs_string(filename, basedir, val, 0); |
824 | } | 828 | } |
@@ -831,7 +835,7 @@ int write_sysfs_string(char *filename, char *basedir, char *val) | |||
831 | * Returns the read integer value >= 0 on success, otherwise a negative error | 835 | * Returns the read integer value >= 0 on success, otherwise a negative error |
832 | * code. | 836 | * code. |
833 | **/ | 837 | **/ |
834 | int read_sysfs_posint(char *filename, char *basedir) | 838 | int read_sysfs_posint(const char *filename, const char *basedir) |
835 | { | 839 | { |
836 | int ret; | 840 | int ret; |
837 | FILE *sysfsfp; | 841 | FILE *sysfsfp; |
@@ -875,7 +879,7 @@ error_free: | |||
875 | * | 879 | * |
876 | * Returns a value >= 0 on success, otherwise a negative error code. | 880 | * Returns a value >= 0 on success, otherwise a negative error code. |
877 | **/ | 881 | **/ |
878 | int read_sysfs_float(char *filename, char *basedir, float *val) | 882 | int read_sysfs_float(const char *filename, const char *basedir, float *val) |
879 | { | 883 | { |
880 | int ret = 0; | 884 | int ret = 0; |
881 | FILE *sysfsfp; | 885 | FILE *sysfsfp; |
diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h index e5eb46ade0a3..379eed9deaea 100644 --- a/tools/iio/iio_utils.h +++ b/tools/iio/iio_utils.h | |||
@@ -63,12 +63,15 @@ void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt); | |||
63 | int build_channel_array(const char *device_dir, | 63 | int build_channel_array(const char *device_dir, |
64 | struct iio_channel_info **ci_array, int *counter); | 64 | struct iio_channel_info **ci_array, int *counter); |
65 | int find_type_by_name(const char *name, const char *type); | 65 | int find_type_by_name(const char *name, const char *type); |
66 | int write_sysfs_int(char *filename, char *basedir, int val); | 66 | int write_sysfs_int(const char *filename, const char *basedir, int val); |
67 | int write_sysfs_int_and_verify(char *filename, char *basedir, int val); | 67 | int write_sysfs_int_and_verify(const char *filename, const char *basedir, |
68 | int write_sysfs_string_and_verify(char *filename, char *basedir, char *val); | 68 | int val); |
69 | int write_sysfs_string(char *filename, char *basedir, char *val); | 69 | int write_sysfs_string_and_verify(const char *filename, const char *basedir, |
70 | int read_sysfs_posint(char *filename, char *basedir); | 70 | const char *val); |
71 | int read_sysfs_float(char *filename, char *basedir, float *val); | 71 | int write_sysfs_string(const char *filename, const char *basedir, |
72 | const char *val); | ||
73 | int read_sysfs_posint(const char *filename, const char *basedir); | ||
74 | int read_sysfs_float(const char *filename, const char *basedir, float *val); | ||
72 | int read_sysfs_string(const char *filename, const char *basedir, char *str); | 75 | int read_sysfs_string(const char *filename, const char *basedir, char *str); |
73 | 76 | ||
74 | #endif /* _IIO_UTILS_H_ */ | 77 | #endif /* _IIO_UTILS_H_ */ |