[PATCH] x86: constify fsname parameter of find_mnt_by_fsname()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



find_mnt_by_fsname() is called with constant strings as its
fsname parameter and does not modify this parameter, thus
it seems appropriate to make the parameter const.

This problem was brought to my attention by gcc:

$ gcc --version
gcc (Debian 6.3.0-18) 6.3.0 20170516
...

$ make
...
kexec/arch/i386/x86-linux-setup.c: In function ‘get_bootparam’:
kexec/arch/i386/x86-linux-setup.c:447:33: warning: passing argument 1 of ‘find_mnt_by_fsname’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  sysfs_mnt = find_mnt_by_fsname("sysfs");
                                 ^~~~~~~
kexec/arch/i386/x86-linux-setup.c:422:7: note: expected ‘char *’ but argument is of type ‘const char *’
 char *find_mnt_by_fsname(char *fsname)
       ^~~~~~~~~~~~~~~~~~
kexec/arch/i386/x86-linux-setup.c:458:36: warning: passing argument 1 of ‘find_mnt_by_fsname’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   debugfs_mnt = find_mnt_by_fsname("debugfs");
                                    ^~~~~~~~~
kexec/arch/i386/x86-linux-setup.c:422:7: note: expected ‘char *’ but argument is of type ‘const char *’
 char *find_mnt_by_fsname(char *fsname)
...

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>
---
 kexec/arch/i386/x86-linux-setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index 2152a2191743..181d7dba2c23 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -419,7 +419,7 @@ out:
  * to be mounted once (sysfs, debugsfs, proc), as it will return the first
  * instance listed in mtab.
  */
-char *find_mnt_by_fsname(char *fsname)
+char *find_mnt_by_fsname(const char *fsname)
 {
 	FILE *mtab;
 	struct mntent *mnt;
-- 
2.11.0


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux