From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] main.conf: Fix parsing of mode options
Date: Thu, 17 Feb 2022 18:16:05 -0800 [thread overview]
Message-ID: <20220218021605.3126182-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This replace the of g_key_file_get_integer which is limited to only
decimal values to g_key_file_get_string and then use strtol to convert
the string value to integer.
Fixes: https://github.com/bluez/bluez/issues/293
---
src/main.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/main.c b/src/main.c
index bf9d398e4..a448320c1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -354,13 +354,22 @@ static void parse_mode_config(GKeyFile *config, const char *group,
for (i = 0; i < params_len; ++i) {
GError *err = NULL;
- int val = g_key_file_get_integer(config, group,
- params[i].val_name, &err);
+ char *str;
+
+ str = g_key_file_get_string(config, group, params[i].val_name,
+ &err);
if (err) {
DBG("%s", err->message);
g_clear_error(&err);
} else {
- info("%s=%d", params[i].val_name, val);
+ char *endptr = NULL;
+ int val;
+
+ val = strtol(str, &endptr, 0);
+ if (!endptr || *endptr != '\0')
+ continue;
+
+ info("%s=%s(%d)", params[i].val_name, str, val);
val = MAX(val, params[i].min);
val = MIN(val, params[i].max);
--
2.35.1
next reply other threads:[~2022-02-18 2:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-18 2:16 Luiz Augusto von Dentz [this message]
2022-02-18 3:27 ` [BlueZ] main.conf: Fix parsing of mode options bluez.test.bot
2022-02-18 21:22 ` Luiz Augusto von Dentz
2022-02-18 6:28 ` [PATCH BlueZ] " Paul Menzel
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=20220218021605.3126182-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.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