binutils: fix C23 -Wdiscarded-qualifiers errors
Fixes -Wdiscarded-qualifiers errors in binutils by correctly handling const char* return values from strchr.
This commit resolves -Wdiscarded-qualifiers errors in binutils, which arise when assigning the return value of strchr (which is now a const char* when passed a const char*) to a non-const char*. The affected files are addr2line.c, nm.c, and prdbg.c.
In Details
This commit addresses const correctness issues within binutils utilities, specifically in addr2line.c, nm.c, and prdbg.c. The core issue revolves around the return type of strchr in C23, which is now const char* when the input is const. This change updates the code to handle the const char* return type, resolving the -Wdiscarded-qualifiers warnings.
For Context
In C programming, the const keyword is used to indicate that a variable's value should not be modified. When a function like strchr returns a pointer to a character within a string, the const qualifier ensures that the pointed-to character is not inadvertently changed. This commit updates the code to respect these const qualifiers, preventing potential errors and improving code robustness.