public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Rudi Heitbaum <rudi@heitbaum.com>
To: linux-media@vger.kernel.org
Cc: rudi@heitbaum.com
Subject: [PATCH v4l-utils] treewide: fix discards 'const' qualifier from pointer
Date: Mon, 16 Feb 2026 09:08:54 +0000	[thread overview]
Message-ID: <aZLepuHgTGpgBc2m@f4d934329c4f> (raw)

For ISO C23, the functions strchr, strrchr, and strstr that return
pointers into their input arrays now have definitions as macros that
return a pointer to a const-qualified type when the input argument is
a pointer to a const-qualified type.

Update to const type for variable, as returned string is only used in
comparisons which const can be used.

fixes:
    ../lib/libdvbv5/dvb-dev-local.c:220:19: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      220 |                 p = strstr(pci_dev, "0x");
          |                   ^
    ../lib/libdvbv5/dvb-dev-local.c:224:19: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      224 |                 p = strstr(pci_vend, "0x");
          |                   ^
    ../utils/libmedia_dev/get_media_devices.c: In function 'get_associated_device':
    ../utils/libmedia_dev/get_media_devices.c:459:19: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      459 |                 p = strrchr(seek_device, '/');
          |                   ^
    ../utils/ir-ctl/ir-ctl.c: In function 'read_scancode':
    ../utils/ir-ctl/ir-ctl.c:530:19: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      530 |         char *p = strchr(name, ':');
          |                   ^~~~~~

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
---
 lib/libdvbv5/dvb-dev-local.c           | 3 +--
 utils/ir-ctl/ir-ctl.c                  | 2 +-
 utils/libmedia_dev/get_media_devices.c | 3 ++-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libdvbv5/dvb-dev-local.c b/lib/libdvbv5/dvb-dev-local.c
index ea511471..b89a6c87 100644
--- a/lib/libdvbv5/dvb-dev-local.c
+++ b/lib/libdvbv5/dvb-dev-local.c
@@ -208,8 +208,7 @@ static int handle_device_change(struct dvb_device_priv *dvb,
 
 	/* Get optional per-bus fields associated with the device parent */
 	if (!strcmp(bus_type, "pci")) {
-		const char *pci_dev, *pci_vend;
-		char *p;
+		const char *p, *pci_dev, *pci_vend;
 
 		pci_dev = udev_device_get_sysattr_value(parent, "subsystem_device");
 		pci_vend = udev_device_get_sysattr_value(parent, "subsystem_vendor");
diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
index 8600fbe6..d2ff77e4 100644
--- a/utils/ir-ctl/ir-ctl.c
+++ b/utils/ir-ctl/ir-ctl.c
@@ -527,7 +527,7 @@ static struct send *read_scancode(const char *name)
 	struct send *f;
 	unsigned scancode;
 	char *pstr;
-	char *p = strchr(name, ':');
+	const char *p = strchr(name, ':');
 
 	if (!p) {
 		fprintf(stderr, _("error: scancode '%s' must be in protocol:scancode format\n"), name);
diff --git a/utils/libmedia_dev/get_media_devices.c b/utils/libmedia_dev/get_media_devices.c
index 21920867..28efb658 100644
--- a/utils/libmedia_dev/get_media_devices.c
+++ b/utils/libmedia_dev/get_media_devices.c
@@ -452,7 +452,8 @@ const char *get_associated_device(void *opaque,
 	struct media_devices *md = opaque;
 	struct media_device_entry *md_ptr = md->md_entry;
 	int i, found = 0;
-	char *prev, *p;
+	const char *p;
+	char *prev;
 
 	if (seek_type != NONE && seek_device[0]) {
 		/* Get just the device name */
-- 
2.51.0


                 reply	other threads:[~2026-02-16  9:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=aZLepuHgTGpgBc2m@f4d934329c4f \
    --to=rudi@heitbaum.com \
    --cc=linux-media@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox