Skip to content

hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type - #173

Merged
mergify[bot] merged 1 commit into
chaos:masterfrom
erentar:fix-gcc15
Jun 23, 2026
Merged

hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type#173
mergify[bot] merged 1 commit into
chaos:masterfrom
erentar:fix-gcc15

Conversation

@erentar

@erentar erentar commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

duplicate fix from chaos/powerman#216

@garlick

garlick commented Jun 22, 2026

Copy link
Copy Markdown
Member

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.

@garlick

garlick commented Jun 22, 2026

Copy link
Copy Markdown
Member

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 :-)

@erentar
erentar force-pushed the fix-gcc15 branch 2 times, most recently from 7adc062 to f27bc9c Compare June 23, 2026 00:46
@erentar erentar changed the title hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type hostlist.c: fix #172: duplicate fix from chaos/powerman/#216 Jun 23, 2026
@erentar

erentar commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@garlick is this what you had wanted?

@garlick

garlick commented Jun 23, 2026

Copy link
Copy Markdown
Member

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?

@erentar erentar changed the title hostlist.c: fix #172: duplicate fix from chaos/powerman/#216 hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type Jun 23, 2026
@erentar

erentar commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Alright, should be fixed now.

@erentar erentar changed the title hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type, duplicate fix from chaos/powerman#216 Jun 23, 2026
@erentar erentar changed the title hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type, duplicate fix from chaos/powerman#216 hostlist.c: fix #172: gcc15 assignment discards ‘const’ qualifier from pointer target type Jun 23, 2026
@garlick

garlick commented Jun 23, 2026

Copy link
Copy Markdown
Member

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).

@erentar
erentar force-pushed the fix-gcc15 branch 2 times, most recently from 037860a to 18a806b Compare June 23, 2026 20:54
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.
@erentar

erentar commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

I hope i got it right this time

@garlick garlick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thank you.

@mergify

mergify Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added the queued label Jun 23, 2026
@mergify

mergify Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-06-23 21:18 UTC · Rule: default · triggered by rule rebase and merge when passing all checks
  • Checks skipped · PR is already up-to-date
  • Merged2026-06-23 21:18 UTC · at d56db0c55012c8a9ea2d3c72749022292c0f65b8 · merge

This pull request spent 15 seconds in the queue, including 2 seconds running CI.

Required conditions to merge

@mergify
mergify Bot merged commit de51d1e into chaos:master Jun 23, 2026
6 of 7 checks passed
@mergify mergify Bot removed the queued label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants