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
-- 
2.50.1 (Apple Git-155)


Reply via email to