* [PATCHv1 0/4] Remove unsafe batostr
@ 2012-08-07 15:05 Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 1/4] Bluetooth: Use %pMR BT addr print spec instead of batostr Andrei Emeltchenko
` (4 more replies)
0 siblings, 5 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-08-07 15:05 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Since the patch "vsprintf: add %pMR for Bluetooth MAC address" in in linux-next and wireless-testing
remove batostr.
http://git.kernel.org/?p=linux/kernel/git/linville/wireless-testing.git;a=commitdiff;h=76597ff989a1fbaa9b9a1e54007cd759bf257ab7
Andrei Emeltchenko (4):
Bluetooth: Use %pMR BT addr print spec instead of batostr
Bluetooth: trivial: Shorten variable scope
Bluetooth: Use %pMR instead of baswap in seq_show
Bluetooth: trivial: Use preferred method for NULL check
include/net/bluetooth/bluetooth.h | 1 -
net/bluetooth/af_bluetooth.c | 20 ++++++++------------
net/bluetooth/bnep/core.c | 3 +--
net/bluetooth/cmtp/core.c | 2 +-
net/bluetooth/hci_conn.c | 6 +++---
net/bluetooth/hci_core.c | 22 +++++++++++-----------
net/bluetooth/hci_event.c | 15 +++++++--------
net/bluetooth/hci_sysfs.c | 10 +++++-----
net/bluetooth/hidp/core.c | 8 ++++++--
net/bluetooth/l2cap_core.c | 11 +++++------
net/bluetooth/lib.c | 14 --------------
net/bluetooth/rfcomm/core.c | 15 +++++++--------
net/bluetooth/rfcomm/sock.c | 9 ++++-----
net/bluetooth/rfcomm/tty.c | 6 +++---
net/bluetooth/sco.c | 12 ++++++------
15 files changed, 67 insertions(+), 87 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCHv1 1/4] Bluetooth: Use %pMR BT addr print spec instead of batostr
2012-08-07 15:05 [PATCHv1 0/4] Remove unsafe batostr Andrei Emeltchenko
@ 2012-08-07 15:05 ` Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 2/4] Bluetooth: trivial: Shorten variable scope Andrei Emeltchenko
` (3 subsequent siblings)
4 siblings, 0 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-08-07 15:05 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Clean up old unsafe batostr function and use %pMR print specifier
for printing Bluetooth addresses.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/bluetooth.h | 1 -
net/bluetooth/bnep/core.c | 3 +--
net/bluetooth/cmtp/core.c | 2 +-
net/bluetooth/hci_conn.c | 6 +++---
net/bluetooth/hci_core.c | 22 +++++++++++-----------
net/bluetooth/hci_event.c | 15 +++++++--------
net/bluetooth/hci_sysfs.c | 10 +++++-----
net/bluetooth/hidp/core.c | 8 ++++++--
net/bluetooth/l2cap_core.c | 11 +++++------
net/bluetooth/lib.c | 14 --------------
net/bluetooth/rfcomm/core.c | 15 +++++++--------
net/bluetooth/rfcomm/sock.c | 9 ++++-----
net/bluetooth/rfcomm/tty.c | 6 +++---
net/bluetooth/sco.c | 12 ++++++------
14 files changed, 59 insertions(+), 75 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index ede0369..2554b3f 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -180,7 +180,6 @@ static inline void bacpy(bdaddr_t *dst, bdaddr_t *src)
}
void baswap(bdaddr_t *dst, bdaddr_t *src);
-char *batostr(bdaddr_t *ba);
/* Common socket structures and functions */
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 4a6620b..a5b6397 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -182,8 +182,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
a2 = data;
data += ETH_ALEN;
- BT_DBG("mc filter %s -> %s",
- batostr((void *) a1), batostr((void *) a2));
+ BT_DBG("mc filter %pMR -> %pMR", a1, a2);
/* Iterate from a1 to a2 */
set_bit(bnep_mc_hash(a1), (ulong *) &s->mc_filter);
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 6c9c1fd..e0a6ebf 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -353,7 +353,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
BT_DBG("mtu %d", session->mtu);
- sprintf(session->name, "%s", batostr(&bt_sk(sock->sk)->dst));
+ sprintf(session->name, "%pMR", &bt_sk(sock->sk)->dst);
session->sock = sock;
session->state = BT_CONFIG;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 5ad7da2..3ec5fc2 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -319,7 +319,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
{
struct hci_conn *conn;
- BT_DBG("%s dst %s", hdev->name, batostr(dst));
+ BT_DBG("%s dst %pMR", hdev->name, dst);
conn = kzalloc(sizeof(struct hci_conn), GFP_KERNEL);
if (!conn)
@@ -436,7 +436,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
int use_src = bacmp(src, BDADDR_ANY);
struct hci_dev *hdev = NULL, *d;
- BT_DBG("%s -> %s", batostr(src), batostr(dst));
+ BT_DBG("%pMR -> %pMR", src, dst);
read_lock(&hci_dev_list_lock);
@@ -479,7 +479,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
struct hci_conn *sco;
struct hci_conn *le;
- BT_DBG("%s dst %s", hdev->name, batostr(dst));
+ BT_DBG("%s dst %pMR", hdev->name, dst);
if (type == LE_LINK) {
le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index fa974a1..28bab9d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -403,7 +403,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev,
struct discovery_state *cache = &hdev->discovery;
struct inquiry_entry *e;
- BT_DBG("cache %p, %s", cache, batostr(bdaddr));
+ BT_DBG("cache %p, %pMR", cache, bdaddr);
list_for_each_entry(e, &cache->all, all) {
if (!bacmp(&e->data.bdaddr, bdaddr))
@@ -419,7 +419,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev,
struct discovery_state *cache = &hdev->discovery;
struct inquiry_entry *e;
- BT_DBG("cache %p, %s", cache, batostr(bdaddr));
+ BT_DBG("cache %p, %pMR", cache, bdaddr);
list_for_each_entry(e, &cache->unknown, list) {
if (!bacmp(&e->data.bdaddr, bdaddr))
@@ -436,7 +436,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev,
struct discovery_state *cache = &hdev->discovery;
struct inquiry_entry *e;
- BT_DBG("cache %p bdaddr %s state %d", cache, batostr(bdaddr), state);
+ BT_DBG("cache %p bdaddr %pMR state %d", cache, bdaddr, state);
list_for_each_entry(e, &cache->resolve, list) {
if (!bacmp(bdaddr, BDADDR_ANY) && e->name_state == state)
@@ -473,7 +473,7 @@ bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
struct discovery_state *cache = &hdev->discovery;
struct inquiry_entry *ie;
- BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr));
+ BT_DBG("cache %p, %pMR", cache, &data->bdaddr);
if (ssp)
*ssp = data->ssp_mode;
@@ -1255,7 +1255,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
list_add(&key->list, &hdev->link_keys);
}
- BT_DBG("%s key for %s type %u", hdev->name, batostr(bdaddr), type);
+ BT_DBG("%s key for %pMR type %u", hdev->name, bdaddr, type);
/* Some buggy controller combinations generate a changed
* combination key for legacy pairing even when there's no
@@ -1334,7 +1334,7 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
if (!key)
return -ENOENT;
- BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+ BT_DBG("%s removing %pMR", hdev->name, bdaddr);
list_del(&key->list);
kfree(key);
@@ -1350,7 +1350,7 @@ int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr)
if (bacmp(bdaddr, &k->bdaddr))
continue;
- BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+ BT_DBG("%s removing %pMR", hdev->name, bdaddr);
list_del(&k->list);
kfree(k);
@@ -1397,7 +1397,7 @@ int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr)
if (!data)
return -ENOENT;
- BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+ BT_DBG("%s removing %pMR", hdev->name, bdaddr);
list_del(&data->list);
kfree(data);
@@ -1436,7 +1436,7 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
memcpy(data->hash, hash, sizeof(data->hash));
memcpy(data->randomizer, randomizer, sizeof(data->randomizer));
- BT_DBG("%s for %s", hdev->name, batostr(bdaddr));
+ BT_DBG("%s for %pMR", hdev->name, bdaddr);
return 0;
}
@@ -2307,8 +2307,8 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
/* Kill stalled connections */
list_for_each_entry_rcu(c, &h->list, list) {
if (c->type == type && c->sent) {
- BT_ERR("%s killing stalled connection %s",
- hdev->name, batostr(&c->dst));
+ BT_ERR("%s killing stalled connection %pMR",
+ hdev->name, &c->dst);
hci_acl_disconn(c, HCI_ERROR_REMOTE_USER_TERM);
}
}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 32e21ad..f3a4568 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1209,7 +1209,7 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
- BT_DBG("%s bdaddr %s hcon %p", hdev->name, batostr(&cp->bdaddr), conn);
+ BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn);
if (status) {
if (conn && conn->state == BT_CONNECT) {
@@ -1627,8 +1627,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
return;
}
- BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&conn->dst),
- conn);
+ BT_DBG("%s bdaddr %pMR conn %p", hdev->name, &conn->dst, conn);
conn->state = BT_CLOSED;
mgmt_connect_failed(hdev, &conn->dst, conn->type,
@@ -1805,7 +1804,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
struct hci_ev_conn_request *ev = (void *) skb->data;
int mask = hdev->link_mode;
- BT_DBG("%s bdaddr %s type 0x%x", hdev->name, batostr(&ev->bdaddr),
+ BT_DBG("%s bdaddr %pMR type 0x%x", hdev->name, &ev->bdaddr,
ev->link_type);
mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type);
@@ -2669,13 +2668,13 @@ static void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
key = hci_find_link_key(hdev, &ev->bdaddr);
if (!key) {
- BT_DBG("%s link key not found for %s", hdev->name,
- batostr(&ev->bdaddr));
+ BT_DBG("%s link key not found for %pMR", hdev->name,
+ &ev->bdaddr);
goto not_found;
}
- BT_DBG("%s found key type %u for %s", hdev->name, key->type,
- batostr(&ev->bdaddr));
+ BT_DBG("%s found key type %u for %pMR", hdev->name, key->type,
+ &ev->bdaddr);
if (!test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags) &&
key->type == HCI_LK_DEBUG_COMBINATION) {
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index a20e61c..55cceee 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -38,7 +38,7 @@ static ssize_t show_link_address(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct hci_conn *conn = to_hci_conn(dev);
- return sprintf(buf, "%s\n", batostr(&conn->dst));
+ return sprintf(buf, "%pMR\n", &conn->dst);
}
static ssize_t show_link_features(struct device *dev,
@@ -224,7 +224,7 @@ static ssize_t show_address(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct hci_dev *hdev = to_hci_dev(dev);
- return sprintf(buf, "%s\n", batostr(&hdev->bdaddr));
+ return sprintf(buf, "%pMR\n", &hdev->bdaddr);
}
static ssize_t show_features(struct device *dev,
@@ -406,8 +406,8 @@ static int inquiry_cache_show(struct seq_file *f, void *p)
list_for_each_entry(e, &cache->all, all) {
struct inquiry_data *data = &e->data;
- seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
- batostr(&data->bdaddr),
+ seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
+ &data->bdaddr,
data->pscan_rep_mode, data->pscan_period_mode,
data->pscan_mode, data->dev_class[2],
data->dev_class[1], data->dev_class[0],
@@ -440,7 +440,7 @@ static int blacklist_show(struct seq_file *f, void *p)
hci_dev_lock(hdev);
list_for_each_entry(b, &hdev->blacklist, list)
- seq_printf(f, "%s\n", batostr(&b->bdaddr));
+ seq_printf(f, "%pMR\n", &b->bdaddr);
hci_dev_unlock(hdev);
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index ccd985d..0c00284 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -932,8 +932,12 @@ static int hidp_setup_hid(struct hidp_session *session,
hid->country = req->country;
strncpy(hid->name, req->name, 128);
- strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64);
- strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64);
+
+ snprintf(hid->phys, sizeof(hid->phys), "%pMR",
+ &bt_sk(session->ctrl_sock->sk)->src);
+
+ snprintf(hid->uniq, sizeof(hid->uniq), "%pMR",
+ &bt_sk(session->ctrl_sock->sk)->dst);
hid->dev.parent = &session->conn->dev;
hid->ll_driver = &hidp_hid_driver;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c7b7b1f..56b98ba 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1504,7 +1504,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
__u8 auth_type;
int err;
- BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst),
+ BT_DBG("%pMR -> %pMR (type %u) psm 0x%2.2x", src, dst,
dst_type, __le16_to_cpu(chan->psm));
hdev = hci_get_route(dst, src);
@@ -5382,7 +5382,7 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr)
int exact = 0, lm1 = 0, lm2 = 0;
struct l2cap_chan *c;
- BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
+ BT_DBG("hdev %s, bdaddr %pMR", hdev->name, bdaddr);
/* Find listening sockets and check their link_mode */
read_lock(&chan_list_lock);
@@ -5412,7 +5412,7 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
{
struct l2cap_conn *conn;
- BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
+ BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status);
if (!status) {
conn = l2cap_conn_add(hcon, status);
@@ -5691,9 +5691,8 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p)
list_for_each_entry(c, &chan_list, global_l) {
struct sock *sk = c->sk;
- seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n",
- batostr(&bt_sk(sk)->src),
- batostr(&bt_sk(sk)->dst),
+ seq_printf(f, "%pMR %pMR %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n",
+ &bt_sk(sk)->src, &bt_sk(sk)->dst,
c->state, __le16_to_cpu(c->psm),
c->scid, c->dcid, c->imtu, c->omtu,
c->sec_level, c->mode);
diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c
index e1c9752..b3fbc73 100644
--- a/net/bluetooth/lib.c
+++ b/net/bluetooth/lib.c
@@ -41,20 +41,6 @@ void baswap(bdaddr_t *dst, bdaddr_t *src)
}
EXPORT_SYMBOL(baswap);
-char *batostr(bdaddr_t *ba)
-{
- static char str[2][18];
- static int i = 1;
-
- i ^= 1;
- sprintf(str[i], "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
- ba->b[5], ba->b[4], ba->b[3],
- ba->b[2], ba->b[1], ba->b[0]);
-
- return str[i];
-}
-EXPORT_SYMBOL(batostr);
-
/* Bluetooth error codes to Unix errno mapping */
int bt_to_errno(__u16 code)
{
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index c75107e..fb1d83d 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -377,8 +377,8 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst,
int err = 0;
u8 dlci;
- BT_DBG("dlc %p state %ld %s %s channel %d",
- d, d->state, batostr(src), batostr(dst), channel);
+ BT_DBG("dlc %p state %ld %pMR -> %pMR channel %d",
+ d, d->state, src, dst, channel);
if (channel < 1 || channel > 30)
return -EINVAL;
@@ -676,7 +676,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
struct socket *sock;
struct sock *sk;
- BT_DBG("%s %s", batostr(src), batostr(dst));
+ BT_DBG("%pMR -> %pMR", src, dst);
*err = rfcomm_l2sock_create(&sock);
if (*err < 0)
@@ -2125,11 +2125,10 @@ static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
list_for_each_entry(d, &s->dlcs, list) {
struct sock *sk = s->sock->sk;
- seq_printf(f, "%s %s %ld %d %d %d %d\n",
- batostr(&bt_sk(sk)->src),
- batostr(&bt_sk(sk)->dst),
- d->state, d->dlci, d->mtu,
- d->rx_credits, d->tx_credits);
+ seq_printf(f, "%pMR %pMR %ld %d %d %d %d\n",
+ &bt_sk(sk)->src, &bt_sk(sk)->dst,
+ d->state, d->dlci, d->mtu,
+ d->rx_credits, d->tx_credits);
}
}
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 260821a..867a065 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -334,7 +334,7 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
struct sock *sk = sock->sk;
int err = 0;
- BT_DBG("sk %p %s", sk, batostr(&sa->rc_bdaddr));
+ BT_DBG("sk %p %pMR", sk, &sa->rc_bdaddr);
if (!addr || addr->sa_family != AF_BLUETOOTH)
return -EINVAL;
@@ -973,10 +973,9 @@ static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
read_lock(&rfcomm_sk_list.lock);
sk_for_each(sk, node, &rfcomm_sk_list.head) {
- seq_printf(f, "%s %s %d %d\n",
- batostr(&bt_sk(sk)->src),
- batostr(&bt_sk(sk)->dst),
- sk->sk_state, rfcomm_pi(sk)->channel);
+ seq_printf(f, "%pMR %pMR %d %d\n",
+ &bt_sk(sk)->src, &bt_sk(sk)->dst,
+ sk->sk_state, rfcomm_pi(sk)->channel);
}
read_unlock(&rfcomm_sk_list.lock);
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index cb96077..6baf64d 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -166,7 +166,7 @@ static struct device *rfcomm_get_device(struct rfcomm_dev *dev)
static ssize_t show_address(struct device *tty_dev, struct device_attribute *attr, char *buf)
{
struct rfcomm_dev *dev = dev_get_drvdata(tty_dev);
- return sprintf(buf, "%s\n", batostr(&dev->dst));
+ return sprintf(buf, "%pMR\n", &dev->dst);
}
static ssize_t show_channel(struct device *tty_dev, struct device_attribute *attr, char *buf)
@@ -663,8 +663,8 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
if (!dev)
return -ENODEV;
- BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst),
- dev->channel, dev->port.count);
+ BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
+ dev->channel, dev->port.count);
spin_lock_irqsave(&dev->port.lock, flags);
if (++dev->port.count > 1) {
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index caa109d..5729f1b 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -163,7 +163,7 @@ static int sco_connect(struct sock *sk)
struct hci_dev *hdev;
int err, type;
- BT_DBG("%s -> %s", batostr(src), batostr(dst));
+ BT_DBG("%pMR -> %pMR", src, dst);
hdev = hci_get_route(dst, src);
if (!hdev)
@@ -451,7 +451,7 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
struct sock *sk = sock->sk;
int err = 0;
- BT_DBG("sk %p %s", sk, batostr(&sa->sco_bdaddr));
+ BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr);
if (!addr || addr->sa_family != AF_BLUETOOTH)
return -EINVAL;
@@ -894,7 +894,7 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr)
struct hlist_node *node;
int lm = 0;
- BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
+ BT_DBG("hdev %s, bdaddr %pMR", hdev->name, bdaddr);
/* Find listening sockets */
read_lock(&sco_sk_list.lock);
@@ -915,7 +915,7 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr)
void sco_connect_cfm(struct hci_conn *hcon, __u8 status)
{
- BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
+ BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status);
if (!status) {
struct sco_conn *conn;
@@ -960,8 +960,8 @@ static int sco_debugfs_show(struct seq_file *f, void *p)
read_lock(&sco_sk_list.lock);
sk_for_each(sk, node, &sco_sk_list.head) {
- seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src),
- batostr(&bt_sk(sk)->dst), sk->sk_state);
+ seq_printf(f, "%pMR %pMR %d\n", &bt_sk(sk)->src,
+ &bt_sk(sk)->dst, sk->sk_state);
}
read_unlock(&sco_sk_list.lock);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCHv1 2/4] Bluetooth: trivial: Shorten variable scope
2012-08-07 15:05 [PATCHv1 0/4] Remove unsafe batostr Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 1/4] Bluetooth: Use %pMR BT addr print spec instead of batostr Andrei Emeltchenko
@ 2012-08-07 15:05 ` Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 3/4] Bluetooth: Use %pMR instead of baswap in seq_show Andrei Emeltchenko
` (2 subsequent siblings)
4 siblings, 0 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-08-07 15:05 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Make code more clear by moving sk and bt vars to the place where
they are actually used.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/af_bluetooth.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 58f9762..1b88fe4 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -567,8 +567,6 @@ static void bt_seq_stop(struct seq_file *seq, void *v)
static int bt_seq_show(struct seq_file *seq, void *v)
{
- struct sock *sk;
- struct bt_sock *bt;
struct bt_seq_state *s = seq->private;
struct bt_sock_list *l = s->l;
bdaddr_t src_baswapped, dst_baswapped;
@@ -583,8 +581,8 @@ static int bt_seq_show(struct seq_file *seq, void *v)
seq_putc(seq, '\n');
} else {
- sk = sk_entry(v);
- bt = bt_sk(sk);
+ struct sock *sk = sk_entry(v);
+ struct bt_sock *bt = bt_sk(sk);
baswap(&src_baswapped, &bt->src);
baswap(&dst_baswapped, &bt->dst);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCHv1 3/4] Bluetooth: Use %pMR instead of baswap in seq_show
2012-08-07 15:05 [PATCHv1 0/4] Remove unsafe batostr Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 1/4] Bluetooth: Use %pMR BT addr print spec instead of batostr Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 2/4] Bluetooth: trivial: Shorten variable scope Andrei Emeltchenko
@ 2012-08-07 15:05 ` Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 4/4] Bluetooth: trivial: Use preferred method for NULL check Andrei Emeltchenko
2012-08-07 15:45 ` [PATCHv1 " Marcel Holtmann
4 siblings, 0 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-08-07 15:05 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use new bluetooth address print specifier %pMR for printing
bluetooth addresses instead of dedicated variable and baswap.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/af_bluetooth.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 1b88fe4..a724f6c 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -569,7 +569,6 @@ static int bt_seq_show(struct seq_file *seq, void *v)
{
struct bt_seq_state *s = seq->private;
struct bt_sock_list *l = s->l;
- bdaddr_t src_baswapped, dst_baswapped;
if (v == SEQ_START_TOKEN) {
seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent");
@@ -583,18 +582,17 @@ static int bt_seq_show(struct seq_file *seq, void *v)
} else {
struct sock *sk = sk_entry(v);
struct bt_sock *bt = bt_sk(sk);
- baswap(&src_baswapped, &bt->src);
- baswap(&dst_baswapped, &bt->dst);
- seq_printf(seq, "%pK %-6d %-6u %-6u %-6u %-6lu %pM %pM %-6lu",
+ seq_printf(seq,
+ "%pK %-6d %-6u %-6u %-6u %-6lu %pMR %pMR %-6lu",
sk,
atomic_read(&sk->sk_refcnt),
sk_rmem_alloc_get(sk),
sk_wmem_alloc_get(sk),
sock_i_uid(sk),
sock_i_ino(sk),
- &src_baswapped,
- &dst_baswapped,
+ &bt->src,
+ &bt->dst,
bt->parent? sock_i_ino(bt->parent): 0LU);
if (l->custom_seq_show) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCHv1 4/4] Bluetooth: trivial: Use preferred method for NULL check
2012-08-07 15:05 [PATCHv1 0/4] Remove unsafe batostr Andrei Emeltchenko
` (2 preceding siblings ...)
2012-08-07 15:05 ` [PATCHv1 3/4] Bluetooth: Use %pMR instead of baswap in seq_show Andrei Emeltchenko
@ 2012-08-07 15:05 ` Andrei Emeltchenko
2012-08-15 4:16 ` Gustavo Padovan
2012-08-07 15:45 ` [PATCHv1 " Marcel Holtmann
4 siblings, 1 reply; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-08-07 15:05 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use standard bluetooth way to check NULL pointer !var instead of
var == NULL.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/af_bluetooth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index a724f6c..a9ad589 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -620,7 +620,7 @@ static int bt_seq_open(struct inode *inode, struct file *file)
sk_list = PDE(inode)->data;
s = __seq_open_private(file, &bt_seq_ops,
sizeof(struct bt_seq_state));
- if (s == NULL)
+ if (!s)
return -ENOMEM;
s->l = sk_list;
@@ -642,7 +642,7 @@ int bt_procfs_init(struct module* module, struct net *net, const char *name,
sk_list->fops.release = seq_release_private;
pde = proc_net_fops_create(net, name, 0, &sk_list->fops);
- if (pde == NULL)
+ if (!pde)
return -ENOMEM;
pde->data = sk_list;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCHv1 0/4] Remove unsafe batostr
2012-08-07 15:05 [PATCHv1 0/4] Remove unsafe batostr Andrei Emeltchenko
` (3 preceding siblings ...)
2012-08-07 15:05 ` [PATCHv1 4/4] Bluetooth: trivial: Use preferred method for NULL check Andrei Emeltchenko
@ 2012-08-07 15:45 ` Marcel Holtmann
4 siblings, 0 replies; 16+ messages in thread
From: Marcel Holtmann @ 2012-08-07 15:45 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
> Since the patch "vsprintf: add %pMR for Bluetooth MAC address" in in linux-next and wireless-testing
> remove batostr.
>
> http://git.kernel.org/?p=linux/kernel/git/linville/wireless-testing.git;a=commitdiff;h=76597ff989a1fbaa9b9a1e54007cd759bf257ab7
>
> Andrei Emeltchenko (4):
> Bluetooth: Use %pMR BT addr print spec instead of batostr
> Bluetooth: trivial: Shorten variable scope
> Bluetooth: Use %pMR instead of baswap in seq_show
> Bluetooth: trivial: Use preferred method for NULL check
>
> include/net/bluetooth/bluetooth.h | 1 -
> net/bluetooth/af_bluetooth.c | 20 ++++++++------------
> net/bluetooth/bnep/core.c | 3 +--
> net/bluetooth/cmtp/core.c | 2 +-
> net/bluetooth/hci_conn.c | 6 +++---
> net/bluetooth/hci_core.c | 22 +++++++++++-----------
> net/bluetooth/hci_event.c | 15 +++++++--------
> net/bluetooth/hci_sysfs.c | 10 +++++-----
> net/bluetooth/hidp/core.c | 8 ++++++--
> net/bluetooth/l2cap_core.c | 11 +++++------
> net/bluetooth/lib.c | 14 --------------
> net/bluetooth/rfcomm/core.c | 15 +++++++--------
> net/bluetooth/rfcomm/sock.c | 9 ++++-----
> net/bluetooth/rfcomm/tty.c | 6 +++---
> net/bluetooth/sco.c | 12 ++++++------
> 15 files changed, 67 insertions(+), 87 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCHv1 4/4] Bluetooth: trivial: Use preferred method for NULL check
2012-08-07 15:05 ` [PATCHv1 4/4] Bluetooth: trivial: Use preferred method for NULL check Andrei Emeltchenko
@ 2012-08-15 4:16 ` Gustavo Padovan
2012-08-15 9:57 ` Andrei Emeltchenko
0 siblings, 1 reply; 16+ messages in thread
From: Gustavo Padovan @ 2012-08-15 4:16 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-08-07 18:05:06 +0300]:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Use standard bluetooth way to check NULL pointer !var instead of
> var == NULL.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/af_bluetooth.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
I applied patches 2, 3 and 4 to bluetooth-next. Patch 1 needs rebase. Thanks.
Gustavo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCHv1 4/4] Bluetooth: trivial: Use preferred method for NULL check
2012-08-15 4:16 ` Gustavo Padovan
@ 2012-08-15 9:57 ` Andrei Emeltchenko
2012-08-21 17:55 ` Gustavo Padovan
0 siblings, 1 reply; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-08-15 9:57 UTC (permalink / raw)
To: Gustavo Padovan, linux-bluetooth
Hi Gustavo,
On Wed, Aug 15, 2012 at 01:16:55AM -0300, Gustavo Padovan wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >
> > Use standard bluetooth way to check NULL pointer !var instead of
> > var == NULL.
> >
> > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > ---
> > net/bluetooth/af_bluetooth.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> I applied patches 2, 3 and 4 to bluetooth-next. Patch 1 needs rebase. Thanks.
Patches 1 and 3 needs patch from linux-next and wireless-testing
<------8<------------------------------------------------------------------
| vsprintf: add %pMR for Bluetooth MAC address
|
| author Andrei Emeltchenko <andrei.emeltchenko@intel.com>
| Mon, 30 Jul 2012 21:40:23 +0000 (14:40 -0700)
| committer Linus Torvalds <torvalds@linux-foundation.org>
| Tue, 31 Jul 2012 00:25:14 +0000 (17:25 -0700)
| Bluetooth uses mostly LE byte order which is reversed for visual
| interpretation. Currently in Bluetooth in use unsafe batostr function.
|
| This is a slightly modified version of Joe's patch (sent Sat, Dec 4,
| 2010).
|
| Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
| Cc: Joe Perches <joe@perches.com>
| Cc: Marcel Holtmann <marcel@holtmann.org>
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
| Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
<------8<------------------------------------------------------------------
which adds actual specifier.
Best regards
Andrei Emeltchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCHv1 4/4] Bluetooth: trivial: Use preferred method for NULL check
2012-08-15 9:57 ` Andrei Emeltchenko
@ 2012-08-21 17:55 ` Gustavo Padovan
2012-09-25 9:49 ` [PATCHv2 0/4] Remove unsafe batostr Andrei Emeltchenko
0 siblings, 1 reply; 16+ messages in thread
From: Gustavo Padovan @ 2012-08-21 17:55 UTC (permalink / raw)
To: Andrei Emeltchenko, linux-bluetooth
* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-08-15 12:57:23 +0300]:
> Hi Gustavo,
>
> On Wed, Aug 15, 2012 at 01:16:55AM -0300, Gustavo Padovan wrote:
> > > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > >
> > > Use standard bluetooth way to check NULL pointer !var instead of
> > > var == NULL.
> > >
> > > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > > ---
> > > net/bluetooth/af_bluetooth.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > I applied patches 2, 3 and 4 to bluetooth-next. Patch 1 needs rebase. Thanks.
>
> Patches 1 and 3 needs patch from linux-next and wireless-testing
I dropped them from the tree until this patch lands on bluetooth-next.
Gustavo
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCHv2 0/4] Remove unsafe batostr
2012-08-21 17:55 ` Gustavo Padovan
@ 2012-09-25 9:49 ` Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 1/4] Bluetooth: Use %pMR in debug instead of batostr Andrei Emeltchenko
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-09-25 9:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Since the patch "vsprintf: add %pMR for Bluetooth MAC address" in in bluetooth-next resend the patch series.
Changes:
* v2: Rebase against recent bluetooth-next.
Andrei Emeltchenko (4):
Bluetooth: Use %pMR in debug instead of batostr
Bluetooth: Use %pMR in sprintf/seq_printf instead of batostr
Bluetooth: Use %pMR instead of baswap in seq_show
bluetooth: Remove unneeded batostr function
include/net/bluetooth/bluetooth.h | 1 -
net/bluetooth/af_bluetooth.c | 10 ++++------
net/bluetooth/bnep/core.c | 3 +--
net/bluetooth/cmtp/core.c | 2 +-
net/bluetooth/hci_conn.c | 6 +++---
net/bluetooth/hci_core.c | 22 +++++++++++-----------
net/bluetooth/hci_event.c | 15 +++++++--------
net/bluetooth/hci_sysfs.c | 10 +++++-----
net/bluetooth/hidp/core.c | 8 ++++++--
net/bluetooth/l2cap_core.c | 17 ++++++++---------
net/bluetooth/lib.c | 14 --------------
net/bluetooth/rfcomm/core.c | 15 +++++++--------
net/bluetooth/rfcomm/sock.c | 9 ++++-----
net/bluetooth/rfcomm/tty.c | 6 +++---
net/bluetooth/sco.c | 12 ++++++------
15 files changed, 66 insertions(+), 84 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCHv2 1/4] Bluetooth: Use %pMR in debug instead of batostr
2012-09-25 9:49 ` [PATCHv2 0/4] Remove unsafe batostr Andrei Emeltchenko
@ 2012-09-25 9:49 ` Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 2/4] Bluetooth: Use %pMR in sprintf/seq_printf " Andrei Emeltchenko
` (4 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-09-25 9:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Instead of old unsafe batostr function use %pMR print specifier
for printing Bluetooth addresses in debug and error statements.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/bnep/core.c | 3 +--
net/bluetooth/hci_conn.c | 6 +++---
net/bluetooth/hci_core.c | 22 +++++++++++-----------
net/bluetooth/hci_event.c | 15 +++++++--------
net/bluetooth/l2cap_core.c | 6 +++---
net/bluetooth/rfcomm/core.c | 6 +++---
net/bluetooth/rfcomm/sock.c | 2 +-
net/bluetooth/rfcomm/tty.c | 4 ++--
net/bluetooth/sco.c | 8 ++++----
9 files changed, 35 insertions(+), 37 deletions(-)
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 4a6620b..a5b6397 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -182,8 +182,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
a2 = data;
data += ETH_ALEN;
- BT_DBG("mc filter %s -> %s",
- batostr((void *) a1), batostr((void *) a2));
+ BT_DBG("mc filter %pMR -> %pMR", a1, a2);
/* Iterate from a1 to a2 */
set_bit(bnep_mc_hash(a1), (ulong *) &s->mc_filter);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index b9196a4..53202f6 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -320,7 +320,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
{
struct hci_conn *conn;
- BT_DBG("%s dst %s", hdev->name, batostr(dst));
+ BT_DBG("%s dst %pMR", hdev->name, dst);
conn = kzalloc(sizeof(struct hci_conn), GFP_KERNEL);
if (!conn)
@@ -437,7 +437,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
int use_src = bacmp(src, BDADDR_ANY);
struct hci_dev *hdev = NULL, *d;
- BT_DBG("%s -> %s", batostr(src), batostr(dst));
+ BT_DBG("%pMR -> %pMR", src, dst);
read_lock(&hci_dev_list_lock);
@@ -567,7 +567,7 @@ static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type,
struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
__u8 dst_type, __u8 sec_level, __u8 auth_type)
{
- BT_DBG("%s dst %s type 0x%x", hdev->name, batostr(dst), type);
+ BT_DBG("%s dst %pMR type 0x%x", hdev->name, dst, type);
switch (type) {
case LE_LINK:
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3588f31..bd26cb5 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -405,7 +405,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev,
struct discovery_state *cache = &hdev->discovery;
struct inquiry_entry *e;
- BT_DBG("cache %p, %s", cache, batostr(bdaddr));
+ BT_DBG("cache %p, %pMR", cache, bdaddr);
list_for_each_entry(e, &cache->all, all) {
if (!bacmp(&e->data.bdaddr, bdaddr))
@@ -421,7 +421,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev,
struct discovery_state *cache = &hdev->discovery;
struct inquiry_entry *e;
- BT_DBG("cache %p, %s", cache, batostr(bdaddr));
+ BT_DBG("cache %p, %pMR", cache, bdaddr);
list_for_each_entry(e, &cache->unknown, list) {
if (!bacmp(&e->data.bdaddr, bdaddr))
@@ -438,7 +438,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev,
struct discovery_state *cache = &hdev->discovery;
struct inquiry_entry *e;
- BT_DBG("cache %p bdaddr %s state %d", cache, batostr(bdaddr), state);
+ BT_DBG("cache %p bdaddr %pMR state %d", cache, bdaddr, state);
list_for_each_entry(e, &cache->resolve, list) {
if (!bacmp(bdaddr, BDADDR_ANY) && e->name_state == state)
@@ -475,7 +475,7 @@ bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
struct discovery_state *cache = &hdev->discovery;
struct inquiry_entry *ie;
- BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr));
+ BT_DBG("cache %p, %pMR", cache, &data->bdaddr);
if (ssp)
*ssp = data->ssp_mode;
@@ -1257,7 +1257,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
list_add(&key->list, &hdev->link_keys);
}
- BT_DBG("%s key for %s type %u", hdev->name, batostr(bdaddr), type);
+ BT_DBG("%s key for %pMR type %u", hdev->name, bdaddr, type);
/* Some buggy controller combinations generate a changed
* combination key for legacy pairing even when there's no
@@ -1336,7 +1336,7 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
if (!key)
return -ENOENT;
- BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+ BT_DBG("%s removing %pMR", hdev->name, bdaddr);
list_del(&key->list);
kfree(key);
@@ -1352,7 +1352,7 @@ int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr)
if (bacmp(bdaddr, &k->bdaddr))
continue;
- BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+ BT_DBG("%s removing %pMR", hdev->name, bdaddr);
list_del(&k->list);
kfree(k);
@@ -1399,7 +1399,7 @@ int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr)
if (!data)
return -ENOENT;
- BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+ BT_DBG("%s removing %pMR", hdev->name, bdaddr);
list_del(&data->list);
kfree(data);
@@ -1438,7 +1438,7 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
memcpy(data->hash, hash, sizeof(data->hash));
memcpy(data->randomizer, randomizer, sizeof(data->randomizer));
- BT_DBG("%s for %s", hdev->name, batostr(bdaddr));
+ BT_DBG("%s for %pMR", hdev->name, bdaddr);
return 0;
}
@@ -2309,8 +2309,8 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
/* Kill stalled connections */
list_for_each_entry_rcu(c, &h->list, list) {
if (c->type == type && c->sent) {
- BT_ERR("%s killing stalled connection %s",
- hdev->name, batostr(&c->dst));
+ BT_ERR("%s killing stalled connection %pMR",
+ hdev->name, &c->dst);
hci_acl_disconn(c, HCI_ERROR_REMOTE_USER_TERM);
}
}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 2022b43..6f2b519 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1210,7 +1210,7 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
- BT_DBG("%s bdaddr %s hcon %p", hdev->name, batostr(&cp->bdaddr), conn);
+ BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn);
if (status) {
if (conn && conn->state == BT_CONNECT) {
@@ -1639,8 +1639,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
return;
}
- BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&conn->dst),
- conn);
+ BT_DBG("%s bdaddr %pMR conn %p", hdev->name, &conn->dst, conn);
conn->state = BT_CLOSED;
mgmt_connect_failed(hdev, &conn->dst, conn->type,
@@ -1822,7 +1821,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
struct hci_ev_conn_request *ev = (void *) skb->data;
int mask = hdev->link_mode;
- BT_DBG("%s bdaddr %s type 0x%x", hdev->name, batostr(&ev->bdaddr),
+ BT_DBG("%s bdaddr %pMR type 0x%x", hdev->name, &ev->bdaddr,
ev->link_type);
mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type);
@@ -2705,13 +2704,13 @@ static void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
key = hci_find_link_key(hdev, &ev->bdaddr);
if (!key) {
- BT_DBG("%s link key not found for %s", hdev->name,
- batostr(&ev->bdaddr));
+ BT_DBG("%s link key not found for %pMR", hdev->name,
+ &ev->bdaddr);
goto not_found;
}
- BT_DBG("%s found key type %u for %s", hdev->name, key->type,
- batostr(&ev->bdaddr));
+ BT_DBG("%s found key type %u for %pMR", hdev->name, key->type,
+ &ev->bdaddr);
if (!test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags) &&
key->type == HCI_LK_DEBUG_COMBINATION) {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 2073045..3de48c9 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1448,7 +1448,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
__u8 auth_type;
int err;
- BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst),
+ BT_DBG("%pMR -> %pMR (type %u) psm 0x%2.2x", src, dst,
dst_type, __le16_to_cpu(psm));
hdev = hci_get_route(dst, src);
@@ -5329,7 +5329,7 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr)
int exact = 0, lm1 = 0, lm2 = 0;
struct l2cap_chan *c;
- BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
+ BT_DBG("hdev %s, bdaddr %pMR", hdev->name, bdaddr);
/* Find listening sockets and check their link_mode */
read_lock(&chan_list_lock);
@@ -5359,7 +5359,7 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
{
struct l2cap_conn *conn;
- BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
+ BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status);
if (!status) {
conn = l2cap_conn_add(hcon, status);
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index c75107e..f6d066c 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -377,8 +377,8 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst,
int err = 0;
u8 dlci;
- BT_DBG("dlc %p state %ld %s %s channel %d",
- d, d->state, batostr(src), batostr(dst), channel);
+ BT_DBG("dlc %p state %ld %pMR -> %pMR channel %d",
+ d, d->state, src, dst, channel);
if (channel < 1 || channel > 30)
return -EINVAL;
@@ -676,7 +676,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
struct socket *sock;
struct sock *sk;
- BT_DBG("%s %s", batostr(src), batostr(dst));
+ BT_DBG("%pMR -> %pMR", src, dst);
*err = rfcomm_l2sock_create(&sock);
if (*err < 0)
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 260821a..ebd2f57 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -334,7 +334,7 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
struct sock *sk = sock->sk;
int err = 0;
- BT_DBG("sk %p %s", sk, batostr(&sa->rc_bdaddr));
+ BT_DBG("sk %p %pMR", sk, &sa->rc_bdaddr);
if (!addr || addr->sa_family != AF_BLUETOOTH)
return -EINVAL;
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index cb96077..0e487e9 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -663,8 +663,8 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
if (!dev)
return -ENODEV;
- BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst),
- dev->channel, dev->port.count);
+ BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
+ dev->channel, dev->port.count);
spin_lock_irqsave(&dev->port.lock, flags);
if (++dev->port.count > 1) {
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index dc42b91..347d3b9 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -172,7 +172,7 @@ static int sco_connect(struct sock *sk)
struct hci_dev *hdev;
int err, type;
- BT_DBG("%s -> %s", batostr(src), batostr(dst));
+ BT_DBG("%pMR -> %pMR", src, dst);
hdev = hci_get_route(dst, src);
if (!hdev)
@@ -460,7 +460,7 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
struct sock *sk = sock->sk;
int err = 0;
- BT_DBG("sk %p %s", sk, batostr(&sa->sco_bdaddr));
+ BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr);
if (!addr || addr->sa_family != AF_BLUETOOTH)
return -EINVAL;
@@ -893,7 +893,7 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr)
struct hlist_node *node;
int lm = 0;
- BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
+ BT_DBG("hdev %s, bdaddr %pMR", hdev->name, bdaddr);
/* Find listening sockets */
read_lock(&sco_sk_list.lock);
@@ -914,7 +914,7 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr)
void sco_connect_cfm(struct hci_conn *hcon, __u8 status)
{
- BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
+ BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status);
if (!status) {
struct sco_conn *conn;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCHv2 2/4] Bluetooth: Use %pMR in sprintf/seq_printf instead of batostr
2012-09-25 9:49 ` [PATCHv2 0/4] Remove unsafe batostr Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 1/4] Bluetooth: Use %pMR in debug instead of batostr Andrei Emeltchenko
@ 2012-09-25 9:49 ` Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 3/4] Bluetooth: Use %pMR instead of baswap in seq_show Andrei Emeltchenko
` (3 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-09-25 9:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Instead of old unsafe batostr function use %pMR print specifier
for printing Bluetooth addresses in sprintf and seq_printf
statements.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/cmtp/core.c | 2 +-
net/bluetooth/hci_sysfs.c | 10 +++++-----
net/bluetooth/hidp/core.c | 8 ++++++--
net/bluetooth/l2cap_core.c | 11 +++++------
net/bluetooth/rfcomm/core.c | 9 ++++-----
net/bluetooth/rfcomm/sock.c | 7 +++----
net/bluetooth/rfcomm/tty.c | 2 +-
net/bluetooth/sco.c | 4 ++--
8 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 6c9c1fd..e0a6ebf 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -353,7 +353,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
BT_DBG("mtu %d", session->mtu);
- sprintf(session->name, "%s", batostr(&bt_sk(sock->sk)->dst));
+ sprintf(session->name, "%pMR", &bt_sk(sock->sk)->dst);
session->sock = sock;
session->state = BT_CONFIG;
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index a20e61c..55cceee 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -38,7 +38,7 @@ static ssize_t show_link_address(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct hci_conn *conn = to_hci_conn(dev);
- return sprintf(buf, "%s\n", batostr(&conn->dst));
+ return sprintf(buf, "%pMR\n", &conn->dst);
}
static ssize_t show_link_features(struct device *dev,
@@ -224,7 +224,7 @@ static ssize_t show_address(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct hci_dev *hdev = to_hci_dev(dev);
- return sprintf(buf, "%s\n", batostr(&hdev->bdaddr));
+ return sprintf(buf, "%pMR\n", &hdev->bdaddr);
}
static ssize_t show_features(struct device *dev,
@@ -406,8 +406,8 @@ static int inquiry_cache_show(struct seq_file *f, void *p)
list_for_each_entry(e, &cache->all, all) {
struct inquiry_data *data = &e->data;
- seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
- batostr(&data->bdaddr),
+ seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
+ &data->bdaddr,
data->pscan_rep_mode, data->pscan_period_mode,
data->pscan_mode, data->dev_class[2],
data->dev_class[1], data->dev_class[0],
@@ -440,7 +440,7 @@ static int blacklist_show(struct seq_file *f, void *p)
hci_dev_lock(hdev);
list_for_each_entry(b, &hdev->blacklist, list)
- seq_printf(f, "%s\n", batostr(&b->bdaddr));
+ seq_printf(f, "%pMR\n", &b->bdaddr);
hci_dev_unlock(hdev);
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index ccd985d..0c00284 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -932,8 +932,12 @@ static int hidp_setup_hid(struct hidp_session *session,
hid->country = req->country;
strncpy(hid->name, req->name, 128);
- strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64);
- strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64);
+
+ snprintf(hid->phys, sizeof(hid->phys), "%pMR",
+ &bt_sk(session->ctrl_sock->sk)->src);
+
+ snprintf(hid->uniq, sizeof(hid->uniq), "%pMR",
+ &bt_sk(session->ctrl_sock->sk)->dst);
hid->dev.parent = &session->conn->dev;
hid->ll_driver = &hidp_hid_driver;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 3de48c9..0873345 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5623,12 +5623,11 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p)
list_for_each_entry(c, &chan_list, global_l) {
struct sock *sk = c->sk;
- seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n",
- batostr(&bt_sk(sk)->src),
- batostr(&bt_sk(sk)->dst),
- c->state, __le16_to_cpu(c->psm),
- c->scid, c->dcid, c->imtu, c->omtu,
- c->sec_level, c->mode);
+ seq_printf(f, "%pMR %pMR %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n",
+ &bt_sk(sk)->src, &bt_sk(sk)->dst,
+ c->state, __le16_to_cpu(c->psm),
+ c->scid, c->dcid, c->imtu, c->omtu,
+ c->sec_level, c->mode);
}
read_unlock(&chan_list_lock);
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index f6d066c..fb1d83d 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2125,11 +2125,10 @@ static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
list_for_each_entry(d, &s->dlcs, list) {
struct sock *sk = s->sock->sk;
- seq_printf(f, "%s %s %ld %d %d %d %d\n",
- batostr(&bt_sk(sk)->src),
- batostr(&bt_sk(sk)->dst),
- d->state, d->dlci, d->mtu,
- d->rx_credits, d->tx_credits);
+ seq_printf(f, "%pMR %pMR %ld %d %d %d %d\n",
+ &bt_sk(sk)->src, &bt_sk(sk)->dst,
+ d->state, d->dlci, d->mtu,
+ d->rx_credits, d->tx_credits);
}
}
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index ebd2f57..867a065 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -973,10 +973,9 @@ static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
read_lock(&rfcomm_sk_list.lock);
sk_for_each(sk, node, &rfcomm_sk_list.head) {
- seq_printf(f, "%s %s %d %d\n",
- batostr(&bt_sk(sk)->src),
- batostr(&bt_sk(sk)->dst),
- sk->sk_state, rfcomm_pi(sk)->channel);
+ seq_printf(f, "%pMR %pMR %d %d\n",
+ &bt_sk(sk)->src, &bt_sk(sk)->dst,
+ sk->sk_state, rfcomm_pi(sk)->channel);
}
read_unlock(&rfcomm_sk_list.lock);
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 0e487e9..6baf64d 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -166,7 +166,7 @@ static struct device *rfcomm_get_device(struct rfcomm_dev *dev)
static ssize_t show_address(struct device *tty_dev, struct device_attribute *attr, char *buf)
{
struct rfcomm_dev *dev = dev_get_drvdata(tty_dev);
- return sprintf(buf, "%s\n", batostr(&dev->dst));
+ return sprintf(buf, "%pMR\n", &dev->dst);
}
static ssize_t show_channel(struct device *tty_dev, struct device_attribute *attr, char *buf)
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 347d3b9..450cdcd 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -959,8 +959,8 @@ static int sco_debugfs_show(struct seq_file *f, void *p)
read_lock(&sco_sk_list.lock);
sk_for_each(sk, node, &sco_sk_list.head) {
- seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src),
- batostr(&bt_sk(sk)->dst), sk->sk_state);
+ seq_printf(f, "%pMR %pMR %d\n", &bt_sk(sk)->src,
+ &bt_sk(sk)->dst, sk->sk_state);
}
read_unlock(&sco_sk_list.lock);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCHv2 3/4] Bluetooth: Use %pMR instead of baswap in seq_show
2012-09-25 9:49 ` [PATCHv2 0/4] Remove unsafe batostr Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 1/4] Bluetooth: Use %pMR in debug instead of batostr Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 2/4] Bluetooth: Use %pMR in sprintf/seq_printf " Andrei Emeltchenko
@ 2012-09-25 9:49 ` Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 4/4] bluetooth: Remove unneeded batostr function Andrei Emeltchenko
` (2 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-09-25 9:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use new bluetooth address print specifier %pMR for printing
bluetooth addresses instead of dedicated variable and baswap.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/af_bluetooth.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 9d49ee6..a9ad589 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -569,7 +569,6 @@ static int bt_seq_show(struct seq_file *seq, void *v)
{
struct bt_seq_state *s = seq->private;
struct bt_sock_list *l = s->l;
- bdaddr_t src_baswapped, dst_baswapped;
if (v == SEQ_START_TOKEN) {
seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent");
@@ -583,18 +582,17 @@ static int bt_seq_show(struct seq_file *seq, void *v)
} else {
struct sock *sk = sk_entry(v);
struct bt_sock *bt = bt_sk(sk);
- baswap(&src_baswapped, &bt->src);
- baswap(&dst_baswapped, &bt->dst);
- seq_printf(seq, "%pK %-6d %-6u %-6u %-6u %-6lu %pM %pM %-6lu",
+ seq_printf(seq,
+ "%pK %-6d %-6u %-6u %-6u %-6lu %pMR %pMR %-6lu",
sk,
atomic_read(&sk->sk_refcnt),
sk_rmem_alloc_get(sk),
sk_wmem_alloc_get(sk),
sock_i_uid(sk),
sock_i_ino(sk),
- &src_baswapped,
- &dst_baswapped,
+ &bt->src,
+ &bt->dst,
bt->parent? sock_i_ino(bt->parent): 0LU);
if (l->custom_seq_show) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCHv2 4/4] bluetooth: Remove unneeded batostr function
2012-09-25 9:49 ` [PATCHv2 0/4] Remove unsafe batostr Andrei Emeltchenko
` (2 preceding siblings ...)
2012-09-25 9:49 ` [PATCHv2 3/4] Bluetooth: Use %pMR instead of baswap in seq_show Andrei Emeltchenko
@ 2012-09-25 9:49 ` Andrei Emeltchenko
2012-09-25 16:27 ` [PATCHv2 0/4] Remove unsafe batostr Marcel Holtmann
2012-09-27 21:11 ` Gustavo Padovan
5 siblings, 0 replies; 16+ messages in thread
From: Andrei Emeltchenko @ 2012-09-25 9:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: gustavo
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
batostr is not needed anymore since for printing Bluetooth
addresses we use %pMR specifier.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/bluetooth.h | 1 -
net/bluetooth/lib.c | 14 --------------
2 files changed, 15 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index ede0369..2554b3f 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -180,7 +180,6 @@ static inline void bacpy(bdaddr_t *dst, bdaddr_t *src)
}
void baswap(bdaddr_t *dst, bdaddr_t *src);
-char *batostr(bdaddr_t *ba);
/* Common socket structures and functions */
diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c
index e1c9752..b3fbc73 100644
--- a/net/bluetooth/lib.c
+++ b/net/bluetooth/lib.c
@@ -41,20 +41,6 @@ void baswap(bdaddr_t *dst, bdaddr_t *src)
}
EXPORT_SYMBOL(baswap);
-char *batostr(bdaddr_t *ba)
-{
- static char str[2][18];
- static int i = 1;
-
- i ^= 1;
- sprintf(str[i], "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
- ba->b[5], ba->b[4], ba->b[3],
- ba->b[2], ba->b[1], ba->b[0]);
-
- return str[i];
-}
-EXPORT_SYMBOL(batostr);
-
/* Bluetooth error codes to Unix errno mapping */
int bt_to_errno(__u16 code)
{
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCHv2 0/4] Remove unsafe batostr
2012-09-25 9:49 ` [PATCHv2 0/4] Remove unsafe batostr Andrei Emeltchenko
` (3 preceding siblings ...)
2012-09-25 9:49 ` [PATCHv2 4/4] bluetooth: Remove unneeded batostr function Andrei Emeltchenko
@ 2012-09-25 16:27 ` Marcel Holtmann
2012-09-27 21:11 ` Gustavo Padovan
5 siblings, 0 replies; 16+ messages in thread
From: Marcel Holtmann @ 2012-09-25 16:27 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth, gustavo
Hi Andrei,
> Since the patch "vsprintf: add %pMR for Bluetooth MAC address" in in bluetooth-next resend the patch series.
>
> Changes:
> * v2: Rebase against recent bluetooth-next.
>
> Andrei Emeltchenko (4):
> Bluetooth: Use %pMR in debug instead of batostr
> Bluetooth: Use %pMR in sprintf/seq_printf instead of batostr
> Bluetooth: Use %pMR instead of baswap in seq_show
> bluetooth: Remove unneeded batostr function
>
> include/net/bluetooth/bluetooth.h | 1 -
> net/bluetooth/af_bluetooth.c | 10 ++++------
> net/bluetooth/bnep/core.c | 3 +--
> net/bluetooth/cmtp/core.c | 2 +-
> net/bluetooth/hci_conn.c | 6 +++---
> net/bluetooth/hci_core.c | 22 +++++++++++-----------
> net/bluetooth/hci_event.c | 15 +++++++--------
> net/bluetooth/hci_sysfs.c | 10 +++++-----
> net/bluetooth/hidp/core.c | 8 ++++++--
> net/bluetooth/l2cap_core.c | 17 ++++++++---------
> net/bluetooth/lib.c | 14 --------------
> net/bluetooth/rfcomm/core.c | 15 +++++++--------
> net/bluetooth/rfcomm/sock.c | 9 ++++-----
> net/bluetooth/rfcomm/tty.c | 6 +++---
> net/bluetooth/sco.c | 12 ++++++------
> 15 files changed, 66 insertions(+), 84 deletions(-)
>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCHv2 0/4] Remove unsafe batostr
2012-09-25 9:49 ` [PATCHv2 0/4] Remove unsafe batostr Andrei Emeltchenko
` (4 preceding siblings ...)
2012-09-25 16:27 ` [PATCHv2 0/4] Remove unsafe batostr Marcel Holtmann
@ 2012-09-27 21:11 ` Gustavo Padovan
5 siblings, 0 replies; 16+ messages in thread
From: Gustavo Padovan @ 2012-09-27 21:11 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-09-25 12:49:42 +0300]:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Since the patch "vsprintf: add %pMR for Bluetooth MAC address" in in bluetooth-next resend the patch series.
>
> Changes:
> * v2: Rebase against recent bluetooth-next.
>
> Andrei Emeltchenko (4):
> Bluetooth: Use %pMR in debug instead of batostr
> Bluetooth: Use %pMR in sprintf/seq_printf instead of batostr
> Bluetooth: Use %pMR instead of baswap in seq_show
> bluetooth: Remove unneeded batostr function
>
> include/net/bluetooth/bluetooth.h | 1 -
> net/bluetooth/af_bluetooth.c | 10 ++++------
> net/bluetooth/bnep/core.c | 3 +--
> net/bluetooth/cmtp/core.c | 2 +-
> net/bluetooth/hci_conn.c | 6 +++---
> net/bluetooth/hci_core.c | 22 +++++++++++-----------
> net/bluetooth/hci_event.c | 15 +++++++--------
> net/bluetooth/hci_sysfs.c | 10 +++++-----
> net/bluetooth/hidp/core.c | 8 ++++++--
> net/bluetooth/l2cap_core.c | 17 ++++++++---------
> net/bluetooth/lib.c | 14 --------------
> net/bluetooth/rfcomm/core.c | 15 +++++++--------
> net/bluetooth/rfcomm/sock.c | 9 ++++-----
> net/bluetooth/rfcomm/tty.c | 6 +++---
> net/bluetooth/sco.c | 12 ++++++------
> 15 files changed, 66 insertions(+), 84 deletions(-)
all 4 patches are now applied to bluetooth-next. Thanks.
Gustavo
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2012-09-27 21:11 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-07 15:05 [PATCHv1 0/4] Remove unsafe batostr Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 1/4] Bluetooth: Use %pMR BT addr print spec instead of batostr Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 2/4] Bluetooth: trivial: Shorten variable scope Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 3/4] Bluetooth: Use %pMR instead of baswap in seq_show Andrei Emeltchenko
2012-08-07 15:05 ` [PATCHv1 4/4] Bluetooth: trivial: Use preferred method for NULL check Andrei Emeltchenko
2012-08-15 4:16 ` Gustavo Padovan
2012-08-15 9:57 ` Andrei Emeltchenko
2012-08-21 17:55 ` Gustavo Padovan
2012-09-25 9:49 ` [PATCHv2 0/4] Remove unsafe batostr Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 1/4] Bluetooth: Use %pMR in debug instead of batostr Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 2/4] Bluetooth: Use %pMR in sprintf/seq_printf " Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 3/4] Bluetooth: Use %pMR instead of baswap in seq_show Andrei Emeltchenko
2012-09-25 9:49 ` [PATCHv2 4/4] bluetooth: Remove unneeded batostr function Andrei Emeltchenko
2012-09-25 16:27 ` [PATCHv2 0/4] Remove unsafe batostr Marcel Holtmann
2012-09-27 21:11 ` Gustavo Padovan
2012-08-07 15:45 ` [PATCHv1 " Marcel Holtmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.