You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2022/04/14 07:51:42 UTC
[mynewt-nimble] branch master updated: apps/btshell: Fix peer_addr_type argument parsing
This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 3cc02b2b apps/btshell: Fix peer_addr_type argument parsing
3cc02b2b is described below
commit 3cc02b2b31bdcd69d1acfce1f375a0160fc79516
Author: Magdalena Kasenberg <ma...@codecoup.pl>
AuthorDate: Mon Apr 11 08:22:44 2022 +0200
apps/btshell: Fix peer_addr_type argument parsing
The cmd parser expected a variable named peer_type instead of
peer_addr_type.
---
apps/btshell/src/cmd.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index 6cb27135..69a3095a 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -103,24 +103,27 @@ parse_dev_addr(const char *prefix, const struct kv_pair *addr_types,
if (!prefix) {
name[0] = '\0';
} else {
- written = snprintf(name, sizeof(name) - 1, "%s", prefix);
+ written = snprintf(name, sizeof(name), "%s", prefix);
if (written >= sizeof(name) || written < 0) {
return EINVAL;
}
}
- written = snprintf(name + written, sizeof(name) - written - 1, "%s", "addr");
- if (written >= sizeof(name) || written < 0) {
+ rc = snprintf(name + written, sizeof(name) - written, "%s", "addr");
+ if (rc >= sizeof(name) - written || rc < 0) {
return EINVAL;
}
+ written += rc;
+
rc = parse_arg_addr(name, addr);
if (rc == ENOENT) {
/* not found */
return rc;
} else if (rc == EAGAIN) {
/* address found, but no type provided */
- written = snprintf(name + written, sizeof(name) - written - 1, "%s", "_type");
- if (written >= sizeof(name) || written < 0) {
+ rc = written;
+ written = snprintf(name + written, sizeof(name) - written, "%s", "_type");
+ if (written >= sizeof(name) - rc || written < 0) {
return EINVAL;
}
addr->type = parse_arg_kv(name, addr_types, &rc);
@@ -134,8 +137,9 @@ parse_dev_addr(const char *prefix, const struct kv_pair *addr_types,
return rc;
} else {
/* full address found, but let's just make sure there is no type arg */
+ rc = written;
written = snprintf(name + written, sizeof(name) - written, "%s", "_type");
- if (written >= sizeof(name) || written < 0) {
+ if (written >= sizeof(name) - rc || written < 0) {
return EINVAL;
}
if (parse_arg_extract(name)) {