From: Rudi Heitbaum <rudi@heitbaum.com>
To: linux-bluetooth@vger.kernel.org
Cc: rudi@heitbaum.com
Subject: [PATCH] src: retain const qualifier from pointer
Date: Sat, 7 Feb 2026 11:44:00 +0000 [thread overview]
Message-ID: <aYclgBGSNj0peBdM@f3de6192b473> (raw)
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
next reply other threads:[~2026-02-07 11:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-07 11:44 Rudi Heitbaum [this message]
2026-02-07 12:39 ` src: retain const qualifier from pointer bluez.test.bot
2026-02-17 19:10 ` [PATCH] " patchwork-bot+bluetooth
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=aYclgBGSNj0peBdM@f3de6192b473 \
--to=rudi@heitbaum.com \
--cc=linux-bluetooth@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