public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] src: retain const qualifier from pointer
@ 2026-02-07 11:44 Rudi Heitbaum
  2026-02-07 12:39 ` bluez.test.bot
  2026-02-17 19:10 ` [PATCH] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Rudi Heitbaum @ 2026-02-07 11:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rudi

Since glibc-2.43:

For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
pointers into their input arrays now have definitions as macros that
return a pointer to a const-qualified type when the in put argument
is a pointer to a const-qualified type.

https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html

fixes:
- warning: assignment discards 'const' qualifier from pointer target
    type [-Wdiscarded-qualifiers]
---
 src/shared/shell.c      | 20 +++++++++++---------
 src/textfile.c          |  3 ++-
 tools/hciattach_ath3k.c |  2 +-
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index f014d8f7c..78d58c513 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -525,6 +525,7 @@ static int cmd_exec(const struct bt_shell_menu_entry *entry,
 	wordexp_t w;
 	size_t len;
 	char *man, *opt;
+	const char *man2, *opt2;
 	int flags = WRDE_NOCMD;
 	bool optargs = false;
 
@@ -547,24 +548,24 @@ static int cmd_exec(const struct bt_shell_menu_entry *entry,
 	}
 
 	/* Find last mandatory arguments */
-	man = strrchr(entry->arg, '>');
-	if (!man) {
+	man2 = strrchr(entry->arg, '>');
+	if (!man2) {
 		opt = strdup(entry->arg);
 		goto optional;
 	}
 
-	len = man - entry->arg;
+	len = man2 - entry->arg;
 	if (entry->arg[0] == '<')
 		man = strndup(entry->arg, len + 1);
 	else {
 		/* Find where mandatory arguments start */
-		opt = strrchr(entry->arg, '<');
+		opt2 = strrchr(entry->arg, '<');
 		/* Skip if mandatory arguments are not in the right format */
-		if (!opt || opt > man) {
+		if (!opt2 || opt2 > man2) {
 			opt = strdup(entry->arg);
 			goto optional;
 		}
-		man = strndup(opt, man - opt + 1);
+		man = strndup(opt2, man2 - opt2 + 1);
 		optargs = true;
 	}
 
@@ -972,6 +973,7 @@ static char *cmd_generator(const char *text, int state)
 	static bool default_menu_enabled, menu_enabled, submenu_enabled;
 	static const struct bt_shell_menu *menu;
 	char *cmd;
+	const char *cmd2;
 
 	if (!state) {
 		index = 0;
@@ -1009,11 +1011,11 @@ static char *cmd_generator(const char *text, int state)
 		if (cmd || menu != data.main)
 			return cmd;
 
-		cmd = strrchr(text, '.');
-		if (!cmd)
+		cmd2 = strrchr(text, '.');
+		if (!cmd2)
 			return NULL;
 
-		menu = find_menu(text, cmd - text, NULL);
+		menu = find_menu(text, cmd2 - text, NULL);
 		if (!menu)
 			return NULL;
 
diff --git a/src/textfile.c b/src/textfile.c
index 8188d2ebe..a83f40c4d 100644
--- a/src/textfile.c
+++ b/src/textfile.c
@@ -68,7 +68,8 @@ int create_filename(char *str, size_t size, const char *fmt, ...)
 static int create_dirs(const char *filename, const mode_t mode)
 {
 	struct stat st;
-	char dir[PATH_MAX + 1], *prev, *next;
+	char dir[PATH_MAX + 1];
+	const char *prev, *next;
 	int err;
 
 	err = stat(filename, &st);
diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c
index 0e4bbf04b..5dcee2e87 100644
--- a/tools/hciattach_ath3k.c
+++ b/tools/hciattach_ath3k.c
@@ -303,7 +303,7 @@ struct tag_info {
 
 static inline int update_char_count(const char *buf)
 {
-	char *end_ptr;
+	const char *end_ptr;
 
 	if (strstr(buf, "[") == buf) {
 		end_ptr = strstr(buf, "]");
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-17 19:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-07 11:44 [PATCH] src: retain const qualifier from pointer Rudi Heitbaum
2026-02-07 12:39 ` bluez.test.bot
2026-02-17 19:10 ` [PATCH] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox