From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 3/6] Bluetooth: Remove useless eir_len variable from EIR creation
Date: Thu, 24 Jan 2013 21:03:23 +0200 [thread overview]
Message-ID: <1359054206-19528-4-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1359054206-19528-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
The amount of data encoded so far in the create_eir() function can be
calculated simply through the difference between the data and ptr
pointer variables. The eir_len variable then becomes essentially
useless.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index d4e5313..76ba1fd 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -439,7 +439,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
u8 *uuids_start;
- u16 eir_len = 0;
struct bt_uuid *uuid;
size_t name_len;
@@ -458,7 +457,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
memcpy(ptr + 2, hdev->dev_name, name_len);
- eir_len += (name_len + 2);
ptr += (name_len + 2);
}
@@ -467,7 +465,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr[1] = EIR_TX_POWER;
ptr[2] = (u8) hdev->inq_tx_power;
- eir_len += 3;
ptr += 3;
}
@@ -480,7 +477,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
put_unaligned_le16(hdev->devid_product, ptr + 6);
put_unaligned_le16(hdev->devid_version, ptr + 8);
- eir_len += 10;
ptr += 10;
}
@@ -502,18 +498,16 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
uuids_start[0] = 1;
uuids_start[1] = EIR_UUID16_ALL;
ptr += 2;
- eir_len += 2;
}
/* Stop if not enough space to put next UUID */
- if (eir_len + 2 + sizeof(u16) > HCI_MAX_EIR_LENGTH) {
+ if ((ptr - data) + 2 + sizeof(u16) > HCI_MAX_EIR_LENGTH) {
uuids_start[1] = EIR_UUID16_SOME;
break;
}
*ptr++ = (uuid16 & 0x00ff);
*ptr++ = (uuid16 & 0xff00) >> 8;
- eir_len += sizeof(uuid16);
uuids_start[0] += sizeof(uuid16);
}
}
--
1.7.10.4
next prev parent reply other threads:[~2013-01-24 19:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-24 19:03 [PATCH 0/6] Bluetooth: Add 32 and 128 bit EIR UUID support Johan Hedberg
2013-01-24 19:03 ` [PATCH 1/6] Bluetooth: Split UUIDs to three separate lists Johan Hedberg
2013-01-24 19:03 ` [PATCH 2/6] Bluetooth: Simplify UUID16 list generation for EIR Johan Hedberg
2013-01-24 19:03 ` Johan Hedberg [this message]
2013-01-24 19:03 ` [PATCH 4/6] Bluetooth: Refactor UUID-16 list generation into its own function Johan Hedberg
2013-01-24 20:21 ` Anderson Lizardo
2013-01-24 20:25 ` Anderson Lizardo
2013-01-25 6:37 ` Johan Hedberg
2013-01-24 19:03 ` [PATCH 5/6] Bluetooth: Add support for 32-bit UUIDs in EIR data Johan Hedberg
2013-01-24 19:03 ` [PATCH 6/6] Bluetooth: Add support for 128-bit " Johan Hedberg
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=1359054206-19528-4-git-send-email-johan.hedberg@gmail.com \
--to=johan.hedberg@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