All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Hung <alex.hung@amd.com>
To: <igt-dev@lists.freedesktop.org>
Cc: Alex Hung <alex.hung@amd.com>
Subject: [PATCH i-g-t v2 4/5] tests/i915_pm_sseu: Preserve const qualifiers
Date: Tue, 29 Sep 2026 11:49:49 -0400	[thread overview]
Message-ID: <20260929154950.838280-5-alex.hung@amd.com> (raw)
In-Reply-To: <20260929154950.838280-1-alex.hung@amd.com>

With glibc 2.43, strstr() on const input returns a const pointer.
Storing that result in char * discards const and causes compiler
warnings in the SSEU debugfs parser.

The following warning is observed on Ubuntu 26.04 (wrapped):

  ../tests/intel/i915_pm_sseu.c: In function 'dbg_has_line':
  ../tests/intel/i915_pm_sseu.c:123:21: warning:
    initialization discards 'const' qualifier from pointer target type
    [-Wdiscarded-qualifiers]

Use const char * for the read-only search results. Pass NULL for
the unused strtol() end pointer so the input pointer can remain const.

Assisted-by: Copilot:GPT-6-Astra
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
 tests/intel/i915_pm_sseu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/intel/i915_pm_sseu.c b/tests/intel/i915_pm_sseu.c
index 5dd571a45..a4b92791c 100644
--- a/tests/intel/i915_pm_sseu.c
+++ b/tests/intel/i915_pm_sseu.c
@@ -120,7 +120,7 @@ dbg_get_status_section(const char *title, char **first, char **last)
 static bool
 dbg_has_line(const char *first, const char *last, const char *name)
 {
-	char *pos = strstr(first, name);
+	const char *pos = strstr(first, name);
 
 	return pos != NULL && pos < last;
 }
@@ -128,7 +128,7 @@ dbg_has_line(const char *first, const char *last, const char *name)
 static int
 dbg_get_int(const char *first, const char *last, const char *name)
 {
-	char *pos;
+	const char *pos;
 
 	pos = strstr(first, name);
 	igt_assert(pos != NULL);
@@ -137,13 +137,13 @@ dbg_get_int(const char *first, const char *last, const char *name)
 	pos += 2;
 	igt_assert(pos != last);
 
-	return strtol(pos, &pos, 10);
+	return strtol(pos, NULL, 10);
 }
 
 static bool
 dbg_get_bool(const char *first, const char *last, const char *name)
 {
-	char *pos;
+	const char *pos;
 
 	pos = strstr(first, name);
 	igt_assert(pos != NULL);
-- 
2.53.0


  parent reply	other threads:[~2026-09-29 15:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 15:49 [PATCH i-g-t v2 0/5] Preserve const qualifiers in string parsing Alex Hung
2026-09-29 15:49 ` [PATCH i-g-t v2 1/5] benchmarks/gem_wsim: Preserve const qualifiers Alex Hung
2026-09-30 13:41   ` Kamil Konieczny
2026-09-29 15:49 ` [PATCH i-g-t v2 2/5] tools/intel_reg_spec: " Alex Hung
2026-09-30 13:43   ` Kamil Konieczny
2026-09-29 15:49 ` [PATCH i-g-t v2 3/5] lib: Preserve string " Alex Hung
2026-09-30 13:46   ` Kamil Konieczny
2026-09-29 15:49 ` Alex Hung [this message]
2026-09-30 13:51   ` [PATCH i-g-t v2 4/5] tests/i915_pm_sseu: Preserve " Kamil Konieczny
2026-09-29 15:49 ` [PATCH i-g-t v2 5/5] tests/msm_mapping: Keep parser buffers writable Alex Hung
2026-09-30 13:55   ` Kamil Konieczny
2026-09-30 14:32     ` Rob Clark
2026-10-02 14:17       ` Kamil Konieczny
2026-09-29 17:41 ` ✗ Xe.CI.BAT: failure for Preserve const qualifiers in string parsing (rev2) Patchwork
2026-09-30 14:24   ` Kamil Konieczny
2026-09-29 17:54 ` ✗ i915.CI.BAT: " Patchwork
2026-09-30 14:24   ` Kamil Konieczny
2026-10-01  8:03     ` Ravali, JupallyX
2026-09-29 21:56 ` ✗ Xe.CI.FULL: " Patchwork
2026-09-30 14:33   ` Kamil Konieczny
2026-10-01  7:08 ` ✓ i915.CI.BAT: success " Patchwork
2026-10-02  7:02 ` ✓ i915.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929154950.838280-5-alex.hung@amd.com \
    --to=alex.hung@amd.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.