hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type - #173
Conversation
|
Thanks! Actually a more comprehensive fix for this was proposed in another project: chaos/powerman#216 I'll pull that over here and reference your issue. |
|
Oh, actually I may not get to this right away. If you want to, feel free to pull that change over here (retain the commit title & message and add "duplicating fix from chaos/powerman/#216" or similar) and I'll approve and merge. O/W I'll get to it soon :-) |
7adc062 to
f27bc9c
Compare
|
@garlick is this what you had wanted? |
|
Sorry, no just the one commit from over there with commit message retained. The commit title here shouldn't include the foreign bug reference - I just meant to append it to the commit message. Sorry if I wasn't clear and if you prefer me to do it LMK ok? |
|
Alright, should be fixed now. |
|
The first commit is now not doing anything useful - squash and force push. Also don't forget to add citation to powerman PR that we borrowed in the commit that remains (in the body not the title). |
037860a to
18a806b
Compare
This fix was authored by hector-cao originally for chaos/powerman#216. _parse_single_range() accepts a `const char *str` argument and creates a mutable copy via strdup() into `orig`. However, it was incorrectly calling strchr() and strtoul() on the original const pointer `str` rather than on the mutable copy. This is both a correctness bug and a build failure with modern glibc: - glibc now provides const-preserving overloads of strchr(), returning `const char *` when passed a `const char *`. Assigning this to `char *p` discards the const qualifier, triggering a compile error with -Werror=discarded-qualifiers. - The subsequent `*p++ = '\0'` write through `p` would modify memory via a pointer originally derived from a const string. Fix by using `orig` (the mutable strdup copy) for strchr() and strtoul() calls, which is the correct buffer to mutate.
|
I hope i got it right this time |
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 15 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
duplicate fix from chaos/powerman#216