fix: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
Description of bug fix
Fixes: https://bugzilla.samba.org/show_bug.cgi?id=16006
Since glibc-2.43 and ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers into their input arrays now have definitions as macros that return a pointer to a const-qualified type when the input argument is a pointer to a const-qualified type.
Commits have been separated based on the types of changes made to the code.
Remaining warnings - not addressed - (not third_party/heimdal) are:
cache_mangled_name will need to be refactored - not to modify the const
../../source3/smbd/mangle_hash.c: In function 'cache_mangled_name':
../../source3/smbd/mangle_hash.c:818:23: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
_spoolss_SetPrinterDataEx will need be refactored is oid_string does indeed need to modify r->in.value_name
../../source3/rpc_server/spoolss/srv_spoolss_nt.c: In function '_spoolss_SetPrinterDataEx':
../../source3/rpc_server/spoolss/srv_spoolss_nt.c:10167:20: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
10167 | oid_string = strchr(r->in.value_name, ','); | ^
printing_tdb_migrate_printer will need to be refactored as valuename is modifing the passed in const r.printer_data[j].name
../../source3/printing/nt_printing_migrate.c: In function 'printing_tdb_migrate_printer':
../../source3/printing/nt_printing_migrate.c:317:27: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
317 | valuename = strchr(keyname, '\\');
| ^
Checklist
-
Commits have
Signed-off-by:with name/author being identical to the commit author - (optional) This MR is just one part towards a larger feature.
-
(optional, if backport required) Bugzilla bug filed and
BUG:tag added - Test suite updated with functionality tests
- Test suite updated with negative tests
- Documentation updated
- CI timeout is 3h or higher (see Settings/CICD/General pipelines/ Timeout)
Reviewer's checklist:
- There is a test suite reasonably covering new functionality or modifications
-
Function naming, parameters, return values, types, etc., are consistent
and according to
README.Coding.md - This feature/change has adequate documentation added
- No obvious mistakes in the code