All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Bluetooth: avoid rebuilding hci_sock all the time
@ 2016-01-06 13:38 Johannes Berg
       [not found] ` <1452087520-29599-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2016-01-06 13:38 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo Padovan, Johan Hedberg
  Cc: linux-bluetooth, netdev, Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

Instead, allow using string formatting with send_monitor_note()
and access init_utsname().

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/bluetooth/hci_sock.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 41f579ba447b..15702bad33bb 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -25,9 +25,8 @@
 /* Bluetooth HCI sockets. */
 
 #include <linux/export.h>
+#include <linux/utsname.h>
 #include <asm/unaligned.h>
-#include <generated/compile.h>
-#include <generated/utsrelease.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -385,18 +384,26 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event)
 	return skb;
 }
 
-static void send_monitor_note(struct sock *sk, const char *text)
+static void __printf(2, 3)
+send_monitor_note(struct sock *sk, const char *fmt, ...)
 {
-	size_t len = strlen(text);
+	size_t len;
 	struct hci_mon_hdr *hdr;
 	struct sk_buff *skb;
+	va_list args;
 
+	va_start(args, fmt);
+	len = vsnprintf(NULL, 0, fmt, args);
 	skb = bt_skb_alloc(len + 1, GFP_ATOMIC);
+	if (skb) {
+		vsprintf(skb_put(skb, len), fmt, args);
+		*skb_put(skb, 1) = 0;
+	}
+	va_end(args);
+
 	if (!skb)
 		return;
 
-	strcpy(skb_put(skb, len + 1), text);
-
 	__net_timestamp(skb);
 
 	hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE);
@@ -897,10 +904,11 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
 		 */
 		hci_sock_set_flag(sk, HCI_SOCK_TRUSTED);
 
-		send_monitor_note(sk, "Linux version " UTS_RELEASE
-				      " (" UTS_MACHINE ")");
-		send_monitor_note(sk, "Bluetooth subsystem version "
-				      BT_SUBSYS_VERSION);
+		send_monitor_note(sk, "Linux version %s (%s)",
+				  init_utsname()->release,
+				  init_utsname()->machine);
+		send_monitor_note(sk, "Bluetooth subsystem version %s",
+				  BT_SUBSYS_VERSION);
 		send_monitor_replay(sk);
 
 		atomic_inc(&monitor_promisc);
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Bluetooth: avoid rebuilding hci_sock all the time
  2016-01-06 13:38 [PATCH v2] Bluetooth: avoid rebuilding hci_sock all the time Johannes Berg
@ 2016-01-06 15:22     ` Marcel Holtmann
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2016-01-06 15:22 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Gustavo F. Padovan, Johan Hedberg,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA, Johannes Berg

Hi Johannes,

> Instead, allow using string formatting with send_monitor_note()
> and access init_utsname().
> 
> Signed-off-by: Johannes Berg <johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> net/bluetooth/hci_sock.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Bluetooth: avoid rebuilding hci_sock all the time
@ 2016-01-06 15:22     ` Marcel Holtmann
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2016-01-06 15:22 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Gustavo F. Padovan, Johan Hedberg, linux-bluetooth, netdev,
	Johannes Berg

Hi Johannes,

> Instead, allow using string formatting with send_monitor_note()
> and access init_utsname().
> 
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
> net/bluetooth/hci_sock.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-06 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-06 13:38 [PATCH v2] Bluetooth: avoid rebuilding hci_sock all the time Johannes Berg
     [not found] ` <1452087520-29599-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2016-01-06 15:22   ` Marcel Holtmann
2016-01-06 15:22     ` 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.