All of lore.kernel.org
 help / color / mirror / Atom feed
From: Inga Stotland <inga.stotland@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com>
Subject: [PATCH BlueZ 1/5] mesh: Make helper packet print depends on debug setting
Date: Thu, 28 May 2020 23:37:46 -0700	[thread overview]
Message-ID: <20200529063750.186278-2-inga.stotland@intel.com> (raw)
In-Reply-To: <20200529063750.186278-1-inga.stotland@intel.com>

This changes the utility function print_packet() to check if
daemon is running in debug mode.
---
 mesh/main.c |  3 ++-
 mesh/util.c | 11 +++++++++++
 mesh/util.h |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/mesh/main.c b/mesh/main.c
index c6bf1ff41..1a4e6ba76 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -37,6 +37,7 @@
 #include "mesh/crypto.h"
 #include "mesh/dbus.h"
 #include "mesh/mesh-io.h"
+#include "mesh/util.h"
 
 static const char *config_dir;
 static const char *mesh_conf_fname;
@@ -210,7 +211,7 @@ int main(int argc, char *argv[])
 			detached = false;
 			break;
 		case 'd':
-			l_debug_enable("*");
+			enable_debug();
 			break;
 		case 'c':
 			config_dir = optarg;
diff --git a/mesh/util.c b/mesh/util.c
index 43340f159..7d283331a 100644
--- a/mesh/util.c
+++ b/mesh/util.c
@@ -34,10 +34,15 @@
 
 #include "mesh/util.h"
 
+static bool debug_enabled;
+
 void print_packet(const char *label, const void *data, uint16_t size)
 {
 	struct timeval pkt_time;
 
+	if (!debug_enabled)
+		return;
+
 	gettimeofday(&pkt_time, NULL);
 
 	if (size > 0) {
@@ -154,3 +159,9 @@ void del_path(const char *path)
 {
 	nftw(path, del_fobject, 5, FTW_DEPTH | FTW_PHYS);
 }
+
+void enable_debug(void)
+{
+	debug_enabled = true;
+	l_debug_enable("*");
+}
diff --git a/mesh/util.h b/mesh/util.h
index 092d33041..93c2d8687 100644
--- a/mesh/util.h
+++ b/mesh/util.h
@@ -24,3 +24,4 @@ size_t hex2str(uint8_t *in, size_t in_len, char *out, size_t out_len);
 void print_packet(const char *label, const void *data, uint16_t size);
 int create_dir(const char *dir_name);
 void del_path(const char *path);
+void enable_debug(void);
-- 
2.26.2


  reply	other threads:[~2020-05-29  6:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29  6:37 [PATCH BlueZ 0/5] Mesh clean up Inga Stotland
2020-05-29  6:37 ` Inga Stotland [this message]
2020-05-29  6:37 ` [PATCH BlueZ 2/5] mesh: Debug output " Inga Stotland
2020-05-29 17:22   ` Gix, Brian
2020-05-29  6:37 ` [PATCH BlueZ 3/5] mesh: Remove debug-only related callback for packet send Inga Stotland
2020-05-29  6:37 ` [PATCH BlueZ 4/5] mesh: Clean up style in net.c Inga Stotland
2020-05-29  7:08   ` [BlueZ,4/5] " bluez.test.bot
2020-05-29  6:37 ` [PATCH BlueZ 5/5] mesh: Remove unused functions from net.c Inga Stotland

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=20200529063750.186278-2-inga.stotland@intel.com \
    --to=inga.stotland@intel.com \
    --cc=brian.gix@intel.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 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.