public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Rudi Heitbaum <rudi@heitbaum.com>
To: linux-pci@vger.kernel.org
Cc: rudi@heitbaum.com, mj@ucw.cz
Subject: [PATCH 1/2 pciutils] libpci: ecam: Fix discards const from pointer target
Date: Sun, 22 Feb 2026 00:46:31 +0000	[thread overview]
Message-ID: <aZpR5wfDQ7fg-4cl@4c9b59f0293a> (raw)

endptr is used as the return from strchr(addrs, ',') which is a const
char. endptr is subsequently used as a pointer to the token which is
char. Fix by not reusing endptr, but declare addrsptr as a const char *
pointer for use in the first case addressing the warning.

fixes:
    ecam.c: In function 'parse_next_addrs':
    ecam.c:620:10: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      620 |   endptr = strchr(addrs, ',');
          |          ^

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
---
 lib/ecam.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/ecam.c b/lib/ecam.c
index de8ecb5..65edd82 100644
--- a/lib/ecam.c
+++ b/lib/ecam.c
@@ -603,7 +603,7 @@ static int
 parse_next_addrs(const char *addrs, const char **next, int *domain, u8 *start_bus, u8 *end_bus, u64 *addr, u32 *length)
 {
   u64 ullnum;
-  const char *sep1, *sep2;
+  const char *addrsptr, *sep1, *sep2;
   int addr_len;
   char *endptr;
   long num;
@@ -617,14 +617,14 @@ parse_next_addrs(const char *addrs, const char **next, int *domain, u8 *start_bu
       return 0;
     }
 
-  endptr = strchr(addrs, ',');
-  if (endptr)
-    addr_len = endptr - addrs;
+  addrsptr = strchr(addrs, ',');
+  if (addrsptr)
+    addr_len = addrsptr - addrs;
   else
     addr_len = strlen(addrs);
 
   if (next)
-    *next = endptr ? (endptr+1) : NULL;
+    *next = addrsptr ? (addrsptr+1) : NULL;
 
   sep1 = memchr(addrs, ':', addr_len);
   if (!sep1)
-- 
2.51.0


             reply	other threads:[~2026-02-22  0:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-22  0:46 Rudi Heitbaum [this message]
2026-04-05 16:43 ` [PATCH 1/2 pciutils] libpci: ecam: Fix discards const from pointer target Martin Mareš

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=aZpR5wfDQ7fg-4cl@4c9b59f0293a \
    --to=rudi@heitbaum.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=mj@ucw.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox