From: "Michał Narajowski" <michal.narajowski@codecoup.pl>
To: linux-bluetooth@vger.kernel.org
Cc: "Michał Narajowski" <michal.narajowski@codecoup.pl>
Subject: [PATCH 1/2] Bluetooth: Shorten complete name if no short name in set local name
Date: Tue, 18 Oct 2016 15:10:23 +0200 [thread overview]
Message-ID: <1476796224-14476-1-git-send-email-michal.narajowski@codecoup.pl> (raw)
Generate shortened local name if no short name specified
to simplify appending local name to scan rsp data.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
---
net/bluetooth/mgmt.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7360380..cc6e571 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3103,7 +3103,16 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data,
goto failed;
}
- memcpy(hdev->short_name, cp->short_name, sizeof(hdev->short_name));
+ /* if no short name set and complete name is longer than max
+ * short name length then shorten complete name
+ */
+ if (!strlen(cp->short_name) &&
+ (strlen(cp->name) > HCI_MAX_SHORT_NAME_LENGTH)) {
+ memcpy(hdev->short_name, cp->name, sizeof(hdev->short_name));
+ } else {
+ memcpy(hdev->short_name, cp->short_name,
+ sizeof(hdev->short_name));
+ }
if (!hdev_is_powered(hdev)) {
memcpy(hdev->dev_name, cp->name, sizeof(hdev->dev_name));
--
2.7.4
next reply other threads:[~2016-10-18 13:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 13:10 Michał Narajowski [this message]
2016-10-18 13:10 ` [PATCH 2/2] Bluetooth: Fix append max 11 bytes of name to scan rsp data Michał Narajowski
2016-10-18 13:47 ` [PATCH 1/2] Bluetooth: Shorten complete name if no short name in set local name Marcel Holtmann
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=1476796224-14476-1-git-send-email-michal.narajowski@codecoup.pl \
--to=michal.narajowski@codecoup.pl \
--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;
as well as URLs for NNTP newsgroup(s).