Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hartmut Knaack and committed by
Jonathan Cameron
9d475254 e06e3d71

+22 -15
+13 -9
tools/iio/iio_utils.c
··· 634 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 640 int ret = 0; 640 641 FILE *sysfsfp; ··· 708 707 * 709 708 * Returns a value >= 0 on success, otherwise a negative error code. 710 709 **/ 711 - int write_sysfs_int(char *filename, char *basedir, int val) 710 + int write_sysfs_int(const char *filename, const char *basedir, int val) 712 711 { 713 712 return _write_sysfs_int(filename, basedir, val, 0); 714 713 } ··· 722 721 * 723 722 * Returns a value >= 0 on success, otherwise a negative error code. 724 723 **/ 725 - int write_sysfs_int_and_verify(char *filename, char *basedir, int val) 724 + int write_sysfs_int_and_verify(const char *filename, const char *basedir, 725 + int val) 726 726 { 727 727 return _write_sysfs_int(filename, basedir, val, 1); 728 728 } 729 729 730 - static int _write_sysfs_string(char *filename, char *basedir, char *val, 731 - int verify) 730 + static int _write_sysfs_string(const char *filename, const char *basedir, 731 + const char *val, int verify) 732 732 { 733 733 int ret = 0; 734 734 FILE *sysfsfp; ··· 807 805 * 808 806 * Returns a value >= 0 on success, otherwise a negative error code. 809 807 **/ 810 - int write_sysfs_string_and_verify(char *filename, char *basedir, char *val) 808 + int write_sysfs_string_and_verify(const char *filename, const char *basedir, 809 + const char *val) 811 810 { 812 811 return _write_sysfs_string(filename, basedir, val, 1); 813 812 } ··· 821 818 * 822 819 * Returns a value >= 0 on success, otherwise a negative error code. 823 820 **/ 824 - int write_sysfs_string(char *filename, char *basedir, char *val) 821 + int write_sysfs_string(const char *filename, const char *basedir, 822 + const char *val) 825 823 { 826 824 return _write_sysfs_string(filename, basedir, val, 0); 827 825 } ··· 835 831 * Returns the read integer value >= 0 on success, otherwise a negative error 836 832 * code. 837 833 **/ 838 - int read_sysfs_posint(char *filename, char *basedir) 834 + int read_sysfs_posint(const char *filename, const char *basedir) 839 835 { 840 836 int ret; 841 837 FILE *sysfsfp; ··· 879 875 * 880 876 * Returns a value >= 0 on success, otherwise a negative error code. 881 877 **/ 882 - int read_sysfs_float(char *filename, char *basedir, float *val) 878 + int read_sysfs_float(const char *filename, const char *basedir, float *val) 883 879 { 884 880 int ret = 0; 885 881 FILE *sysfsfp;
+9 -6
tools/iio/iio_utils.h
··· 63 63 int build_channel_array(const char *device_dir, 64 64 struct iio_channel_info **ci_array, int *counter); 65 65 int find_type_by_name(const char *name, const char *type); 66 - int write_sysfs_int(char *filename, char *basedir, int val); 67 - int write_sysfs_int_and_verify(char *filename, char *basedir, int val); 68 - int write_sysfs_string_and_verify(char *filename, char *basedir, char *val); 69 - int write_sysfs_string(char *filename, char *basedir, char *val); 70 - int read_sysfs_posint(char *filename, char *basedir); 71 - int read_sysfs_float(char *filename, char *basedir, float *val); 66 + int write_sysfs_int(const char *filename, const char *basedir, int val); 67 + int write_sysfs_int_and_verify(const char *filename, const char *basedir, 68 + int val); 69 + int write_sysfs_string_and_verify(const char *filename, const char *basedir, 70 + const char *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 75 int read_sysfs_string(const char *filename, const char *basedir, char *str); 73 76 74 77 #endif /* _IIO_UTILS_H_ */