Skip to content

Fix GCC 16 const-correctness violations

Amit Machhiwal kvm qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 2 repliesIn review
  2. v21 patch 1 replySuperseded
  3. v11 patch 3 repliesSuperseded

Changes in v3 from the cover letter

- Harsh: g_strndup will abort the program in case of OOM eventually making it a dead code. Additionally, typecase (suffix - cname). Also, unlikely() is not needed.
- Remove error handling (GLib functions abort on allocation failure)
- Remove unlikely() macro (provides no benefit in initialization code)
- Typecast (suffix - cname)
- Update the commit messages accordingly
- v2: https://lore.kernel.org/all/[email protected]/

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2target/ppc/kvm: Fix const violation when trimming CPU alias suffixtarget/ppc/kvm.c+5 -60 replies
2/2tests/qtest/libqtest: Fix const violation in qtest_verbose()tests/qtest/libqtest.c+4 -50 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAnushree MathurAditya Gupta
SeriesT-b R-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] Fix GCC 16 const-correctness violations

GCC 16 has tightened const-correctness checking and now correctly rejects attempts to modify or assign const-qualified pointers without proper qualification. This series fixes two such violations that cause build failures with GCC 16 when using -Werror=discarded-qualifiers.

Both patches follow the same approach: changing local variables to const-qualified types and using GLib string functions (g_strdup, g_strndup, g_strstr_len, g_getenv) that work correctly with const strings, eliminating the need for in-place modifications.

Changes in v3:
- Harsh: g_strndup will abort the program in case of OOM eventually making it a dead code. Additionally, typecase (suffix - cname). Also, unlikely() is not needed.
- Remove error handling (GLib functions abort on allocation failure)
- Remove unlikely() macro (provides no benefit in initialization code)
- Typecast (suffix - cname)
- Update the commit messages accordingly
- v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Avoid pointer aliasing
- Handle memory allocation failure error
- v1: https://lore.kernel.org/all/[email protected]

Tested on:
- GCC 16.1.1 (no warnings with -Werror=discarded-qualifiers)
- GCC 15.2.1 (backward compatible)

Amit Machhiwal (2):
target/ppc/kvm: Fix const violation when trimming CPU alias suffix tests/qtest/libqtest: Fix const violation in qtest_verbose()

 target/ppc/kvm.c       | 11 +++++------
 tests/qtest/libqtest.c |  9 ++++-----
 2 files changed, 9 insertions(+), 11 deletions(-)

base-commit: ac6721b88df944ade0048822b2b74210f543d656

Signature · 1 line
2.50.1 (Apple Git-155)