* [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag
@ 2015-11-30 11:21 Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 2/4] iwpan/wpan-ping: add some missing static attributes Stefan Schmidt
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Stefan Schmidt @ 2015-11-30 11:21 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt
This was disabled by default and we are now hiding it behind a more generic
DEBUG flag and keep it off by default.
Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
wpan-ping/wpan-ping.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c
index b454ddb..08211c3 100644
--- a/wpan-ping/wpan-ping.c
+++ b/wpan-ping/wpan-ping.c
@@ -49,6 +49,8 @@
/* Set the dispatch header to not 6lowpan for compat */
#define NOT_A_6LOWPAN_FRAME 0x00
+#define DEBUG 0
+
enum {
IEEE802154_ADDR_NONE = 0x0,
IEEE802154_ADDR_SHORT = 0x2,
@@ -195,6 +197,7 @@ static int get_interface_info(struct config *conf) {
return 0;
}
+#if DEBUG
static void dump_packet(unsigned char *buf, int len) {
int i;
@@ -204,6 +207,7 @@ static void dump_packet(unsigned char *buf, int len) {
}
printf("\n");
}
+#endif
static int generate_packet(unsigned char *buf, struct config *conf, unsigned int seq_num) {
int i;
@@ -347,7 +351,9 @@ static void init_server(struct config *conf, int sd) {
perror("recvfrom");
continue;
}
- //dump_packet(buf, len);
+#if DEBUG
+ dump_packet(buf, len);
+#endif
/* Send same packet back */
len = sendto(sd, buf, len, 0, (struct sockaddr *)&src, addrlen);
if (len < 0) {
--
2.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH wpan-tools 2/4] iwpan/wpan-ping: add some missing static attributes
2015-11-30 11:21 [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
@ 2015-11-30 11:21 ` Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 3/4] wpan-ping: remove unused parameter from init_server() Stefan Schmidt
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Stefan Schmidt @ 2015-11-30 11:21 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt
Sparse pointed these out to me.
Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
src/info.c | 6 +++---
src/iwpan.c | 2 +-
wpan-ping/wpan-ping.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/info.c b/src/info.c
index e00ed3e..7c033ec 100644
--- a/src/info.c
+++ b/src/info.c
@@ -148,8 +148,8 @@ static void print_freq_handler(int channel_page, int channel)
static char cca_mode_buf[100];
-const char *print_cca_mode_handler(enum nl802154_cca_modes cca_mode,
- enum nl802154_cca_opts cca_opt)
+static const char *print_cca_mode_handler(enum nl802154_cca_modes cca_mode,
+ enum nl802154_cca_opts cca_opt)
{
switch (cca_mode) {
case NL802154_CCA_ENERGY:
@@ -217,7 +217,7 @@ static const char *commands[NL802154_CMD_MAX + 1] = {
static char cmdbuf[100];
-const char *command_name(enum nl802154_commands cmd)
+static const char *command_name(enum nl802154_commands cmd)
{
if (cmd <= NL802154_CMD_MAX && commands[cmd])
return commands[cmd];
diff --git a/src/iwpan.c b/src/iwpan.c
index e988703..e7781fd 100644
--- a/src/iwpan.c
+++ b/src/iwpan.c
@@ -21,7 +21,7 @@
/* TODO libnl 1.x compatibility code */
-int iwpan_debug = 0;
+static int iwpan_debug = 0;
static int nl802154_init(struct nl802154_state *state)
{
diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c
index 08211c3..665ed93 100644
--- a/wpan-ping/wpan-ping.c
+++ b/wpan-ping/wpan-ping.c
@@ -99,7 +99,7 @@ struct config {
extern char *optarg;
-void usage(const char *name) {
+static void usage(const char *name) {
printf("Usage: %s OPTIONS\n"
"OPTIONS:\n"
"--daemon |-d\n"
--
2.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH wpan-tools 3/4] wpan-ping: remove unused parameter from init_server()
2015-11-30 11:21 [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 2/4] iwpan/wpan-ping: add some missing static attributes Stefan Schmidt
@ 2015-11-30 11:21 ` Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 4/4] wpan-ping: make sure we do not leak conf during wrong options exit Stefan Schmidt
2015-12-01 20:01 ` [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
3 siblings, 0 replies; 6+ messages in thread
From: Stefan Schmidt @ 2015-11-30 11:21 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt
The conf struct was used before but no longer since some refactoring. Remove
the need for this left-over.
Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
wpan-ping/wpan-ping.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c
index 665ed93..edba8dd 100644
--- a/wpan-ping/wpan-ping.c
+++ b/wpan-ping/wpan-ping.c
@@ -333,7 +333,7 @@ static int measure_roundtrip(struct config *conf, int sd) {
return 0;
}
-static void init_server(struct config *conf, int sd) {
+static void init_server(int sd) {
ssize_t len;
unsigned char *buf;
struct sockaddr_ieee802154 src;
@@ -383,7 +383,7 @@ static int init_network(struct config *conf) {
}
if (conf->server)
- init_server(conf, sd);
+ init_server(sd);
else
measure_roundtrip(conf, sd);
--
2.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH wpan-tools 4/4] wpan-ping: make sure we do not leak conf during wrong options exit
2015-11-30 11:21 [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 2/4] iwpan/wpan-ping: add some missing static attributes Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 3/4] wpan-ping: remove unused parameter from init_server() Stefan Schmidt
@ 2015-11-30 11:21 ` Stefan Schmidt
2015-12-01 20:01 ` [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
3 siblings, 0 replies; 6+ messages in thread
From: Stefan Schmidt @ 2015-11-30 11:21 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt
When we hit a wrong option and we are goignt o exit wpan-ping we might have
leaked conf. Not a real problem as we are goign to exit anyway at this point.
Still fix this. Thanks to the smatch tool for pointing this out.
Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
wpan-ping/wpan-ping.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c
index edba8dd..92f4cf8 100644
--- a/wpan-ping/wpan-ping.c
+++ b/wpan-ping/wpan-ping.c
@@ -481,6 +481,7 @@ int main(int argc, char *argv[]) {
if (conf->packet_len >= MAX_PAYLOAD_LEN || conf->packet_len < MIN_PAYLOAD_LEN) {
printf("Packet size must be between %i and %i.\n",
MIN_PAYLOAD_LEN, MAX_PAYLOAD_LEN - 1);
+ free(conf);
return 1;
}
break;
@@ -489,12 +490,15 @@ int main(int argc, char *argv[]) {
break;
case 'v':
fprintf(stdout, "wpan-ping " PACKAGE_VERSION "\n");
+ free(conf);
return 1;
case 'h':
usage(argv[0]);
+ free(conf);
return 1;
default:
usage(argv[0]);
+ free(conf);
return 1;
}
}
--
2.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag
2015-11-30 11:21 [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
` (2 preceding siblings ...)
2015-11-30 11:21 ` [PATCH wpan-tools 4/4] wpan-ping: make sure we do not leak conf during wrong options exit Stefan Schmidt
@ 2015-12-01 20:01 ` Stefan Schmidt
2015-12-01 20:19 ` Alexander Aring
3 siblings, 1 reply; 6+ messages in thread
From: Stefan Schmidt @ 2015-12-01 20:01 UTC (permalink / raw)
To: linux-wpan; +Cc: Alexander Aring
Hello.
If nobody raises a problem with these four patches I will push them
tomorrow.
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag
2015-12-01 20:01 ` [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
@ 2015-12-01 20:19 ` Alexander Aring
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2015-12-01 20:19 UTC (permalink / raw)
To: Stefan Schmidt; +Cc: linux-wpan
On Tue, Dec 01, 2015 at 09:01:23PM +0100, Stefan Schmidt wrote:
> Hello.
>
> If nobody raises a problem with these four patches I will push them
> tomorrow.
>
everything fine for me. Thanks for working on this. :-)
-Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-12-01 20:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-30 11:21 [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 2/4] iwpan/wpan-ping: add some missing static attributes Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 3/4] wpan-ping: remove unused parameter from init_server() Stefan Schmidt
2015-11-30 11:21 ` [PATCH wpan-tools 4/4] wpan-ping: make sure we do not leak conf during wrong options exit Stefan Schmidt
2015-12-01 20:01 ` [PATCH wpan-tools 1/4] wpan-ping: hide packet dump behind DEBUG flag Stefan Schmidt
2015-12-01 20:19 ` Alexander Aring
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.