gprof: Fix discarded-qualifiers problems in source.c
Fixes discarded-qualifiers errors in gprof's source.c due to qualifier-preserving strchr().
This patch addresses -Wdiscarded-qualifiers errors in source.c within the gprof profiler. The errors are caused by the qualifier-preserving behavior of strchr(). The patch declares local pointer variables as const to avoid discarding the const qualifier. Simon Marchi notes that the cast to const char * is unnecessary, and variable bslash at line 187 also needs to be changed.
- contributor
Suggests removing the cast to `const char *` and points out variable `bslash` at line 187 also needs to be changed.
“I think that you can just remove this cast to `const char *`, since `sf->name` is already a `const char *`. There is another spot to change, variable `bslash` at line 187 of the same file.”
In Details
gprof is a performance analysis tool. This patch updates gprof to accommodate changes in how strchr() handles const qualifiers, specifically in source.c where source file names are manipulated.
For Context
gprof is a tool for profiling program execution, helping developers identify performance bottlenecks. This patch fixes compile errors caused by stricter type checking in newer compiler versions when processing source file names.