cifs-utils: mount.cifs.c/parse_options: const variable is being modified
Subsystems (2)
In the mount.cifs.c/parse_options function - data is passed in as const char*.
strchr returns a warning that the const has been discarded since the latest glibc / ISO C22.
code in question is:
889: next_keyword = strchr(data, ','); - returns a const 890: *next_keyword++ = 0; - modifies a const
897: if ((equals = strchr(data, '=')) != NULL) { - returns a const 898: *equals = '\0'; - modifies a const
The warnings are:
../mount.cifs.c: In function 'parse_options':../mount.cifs.c:889:30: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
889 | next_keyword = strchr(data, ','); /* BB handle sep= */
| ^../mount.cifs.c:897:29: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
897 | if ((equals = strchr(data, '=')) != NULL) {
| ^
Regards
Rudi
I don't see this warning on my Ubuntu test system which seems to be current for glibc
Ubuntu GLIBC 2.42-0ubuntu3.1) 2.42
Are you using a newer GLIBC? Do you want to submit a patch to fix this (does an explicit cast fix it?)?
By the way, I didn't see your original email since gmail routed it to spam for some reason
Quoted 30 lines · Rudi Heitbaum
In the mount.cifs.c/parse_options function - data is passed in as const char*.
strchr returns a warning that the const has been discarded since the latest glibc / ISO C22.
code in question is:
889:
next_keyword=strchr(data, ','); - returns a const 890: *next_keyword++ = 0; - modifies a const897: if ((equals =
strchr(data, '=')) != NULL) { - returns a const 898: *equals = '\0'; - modifies a constThe warnings are:
../mount.cifs.c: In function 'parse_options':../mount.cifs.c:889:30: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
889 |next_keyword=strchr(data, ','); /* BB handle sep= */
| ^../mount.cifs.c:897:29: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
897 | if ((equals =strchr(data, '=')) != NULL) {
| ^Regards
Rudi
Signature · 3 lines
Thanks, Steve