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 3/5] lib: Preserve string const qualifiers
Date: Tue, 29 Sep 2026 11:49:48 -0400 [thread overview]
Message-ID: <20260929154950.838280-4-alex.hung@amd.com> (raw)
In-Reply-To: <20260929154950.838280-1-alex.hung@amd.com>
With glibc 2.43, string searches on const input return const pointers.
Storing these results in char * variables causes compiler warnings.
The following warning is observed on Ubuntu 26.04 (wrapped):
../lib/igt_drm_fdinfo.c: In function 'parse_region':
../lib/igt_drm_fdinfo.c:122:4: warning:
assignment discards 'const' qualifier from pointer target type
[-Wdiscarded-qualifiers]
Use const char * for read-only search results and preserve const in
igt_get_dc6_counter() and its callers. Give strtoull() a separate
end pointer in the fdinfo parser so its input pointer can remain
const without a cast.
Assisted-by: Copilot:GPT-6-Astra
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
lib/i915/i915_dp.c | 2 +-
lib/igt_core.c | 2 +-
lib/igt_drm_fdinfo.c | 7 ++++---
lib/igt_pm.c | 10 +++++-----
lib/igt_pm.h | 2 +-
5 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/lib/i915/i915_dp.c b/lib/i915/i915_dp.c
index 3d570f7cc..595010140 100644
--- a/lib/i915/i915_dp.c
+++ b/lib/i915/i915_dp.c
@@ -49,7 +49,7 @@
*/
static int i915_dp_parse_marked_value(const char *buf, char marked_char, int *result)
{
- char *marked_ptr, *val_ptr;
+ const char *marked_ptr, *val_ptr;
/*
* Look for the marked character
diff --git a/lib/igt_core.c b/lib/igt_core.c
index d5dc5324d..b1d045161 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1141,7 +1141,7 @@ static int common_init(int *argc, char **argv,
/* Check for conflicts and calculate space for passed-in extra long options */
for (extra_opt_count = 0; extra_long_opts && extra_long_opts[extra_opt_count].name; extra_opt_count++) {
- char *conflicting_char;
+ const char *conflicting_char;
/* check for conflicts with standard long option values */
for (i = 0; long_options[i].name; i++) {
diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
index 74a90c437..056eb2ca8 100644
--- a/lib/igt_drm_fdinfo.c
+++ b/lib/igt_drm_fdinfo.c
@@ -114,7 +114,8 @@ static int parse_region(const char *name, struct drm_client_fdinfo *info,
const char **region_map, unsigned int region_entries,
uint64_t *val)
{
- char *p;
+ const char *p;
+ char *end;
ssize_t name_len;
int found = -1;
unsigned int i;
@@ -160,8 +161,8 @@ static int parse_region(const char *name, struct drm_client_fdinfo *info,
goto out;
p++;
- *val = strtoull(p, &p, 10);
- p = (char *)ignore_space(p);
+ *val = strtoull(p, &end, 10);
+ p = ignore_space(end);
if (!*p)
goto out;
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 7905deb8d..1e3cc7757 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -1555,7 +1555,7 @@ uint32_t igt_get_dc_counter(const char *dc_data)
{
char *e;
long ret;
- char *s = strchr(dc_data, ':');
+ const char *s = strchr(dc_data, ':');
igt_assert(s);
s++;
@@ -1586,9 +1586,9 @@ bool igt_support_dc6(int debugfs_fd)
*
* Searches for DC6 counter information in the DMC info buffer.
*/
-char *igt_get_dc6_counter(const char *buf)
+const char *igt_get_dc6_counter(const char *buf)
{
- char *str;
+ const char *str;
str = strstr(buf, "DC5 -> DC6 count");
if (!str)
@@ -1607,7 +1607,7 @@ char *igt_get_dc6_counter(const char *buf)
uint32_t igt_read_dc_counter(int debugfs_fd, int dc_flag)
{
char buf[4096];
- char *str;
+ const char *str;
igt_debugfs_simple_read(debugfs_fd, "i915_dmc_info", buf, sizeof(buf));
@@ -1669,7 +1669,7 @@ const char *igt_dc_state_name(int dc_flag)
*/
void igt_require_dc_counter(int debugfs_fd, int dc_flag)
{
- char *str;
+ const char *str;
char buf[4096];
igt_debugfs_simple_read(debugfs_fd, "i915_dmc_info",
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index cd9dceb1e..328875f9c 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -108,7 +108,7 @@ bool igt_has_pci_pm_capability(struct pci_device *pci_dev);
void igt_pm_dpms_toggle(igt_output_t *output);
uint32_t igt_get_dc_counter(const char *dc_data);
bool igt_support_dc6(int debugfs_fd);
-char *igt_get_dc6_counter(const char *buf);
+const char *igt_get_dc6_counter(const char *buf);
uint32_t igt_read_dc_counter(int debugfs_fd, int dc_flag);
bool igt_dc_state_wait_entry(int debugfs_fd, int dc_flag, int prev_dc_count);
const char *igt_dc_state_name(int dc_flag);
--
2.53.0
next prev parent reply other threads:[~2026-09-29 15:51 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 ` Alex Hung [this message]
2026-09-30 13:46 ` [PATCH i-g-t v2 3/5] lib: Preserve string " Kamil Konieczny
2026-09-29 15:49 ` [PATCH i-g-t v2 4/5] tests/i915_pm_sseu: Preserve " Alex Hung
2026-09-30 13:51 ` 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-4-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.