linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iw:  Flush stdout when printing events.
@ 2010-09-29  0:30 greearb
  2010-09-29  6:59 ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: greearb @ 2010-09-29  0:30 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

This lets one pipe output of iw event properly.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 129db1a... 60bafc5... M	event.c
 event.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/event.c b/event.c
index 129db1a..60bafc5 100644
--- a/event.c
+++ b/event.c
@@ -130,12 +130,16 @@ static void parse_cqm_event(struct nlattr *tb)
 
 static int print_event(struct nl_msg *msg, void *arg)
 {
-#define PARSE_BEACON_CHAN(_attr, _chan) do { \
-	r = parse_beacon_hint_chan(tb[_attr], \
-				   &_chan); \
-	if (r) \
-		return NL_SKIP; \
-} while (0)
+
+#define PARSE_BEACON_CHAN(_attr, _chan) do {		\
+		r = parse_beacon_hint_chan(tb[_attr],	\
+					   &_chan);	\
+		if (r) {				\
+			fflush(stdout);			\
+			return NL_SKIP;			\
+		}					\
+	} while (0)
+
 	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
 	struct nlattr *tb[NL80211_ATTR_MAX + 1], *nst;
 	struct print_event_args *args = arg;
@@ -349,6 +353,7 @@ static int print_event(struct nl_msg *msg, void *arg)
 		break;
 	}
 
+	fflush(stdout);
 	return NL_SKIP;
 #undef PARSE_BEACON_CHAN
 }
@@ -369,8 +374,8 @@ static int wait_event(struct nl_msg *msg, void *arg)
 	for (i = 0; i < wait->n_cmds; i++) {
 		if (gnlh->cmd == wait->cmds[i]) {
 			wait->cmd = gnlh->cmd;
-		if (wait->pargs)
-			print_event(msg, wait->pargs);
+			if (wait->pargs)
+				print_event(msg, wait->pargs);
 		}
 	}
 
-- 
1.5.4.3


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

* Re: [PATCH] iw:  Flush stdout when printing events.
  2010-09-29  0:30 [PATCH] iw: Flush stdout when printing events greearb
@ 2010-09-29  6:59 ` Johannes Berg
  2010-09-29 20:21   ` Ben Greear
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2010-09-29  6:59 UTC (permalink / raw)
  To: greearb; +Cc: linux-wireless

On Tue, 2010-09-28 at 17:30 -0700, greearb@candelatech.com wrote:

> -#define PARSE_BEACON_CHAN(_attr, _chan) do { \
> -	r = parse_beacon_hint_chan(tb[_attr], \
> -				   &_chan); \
> -	if (r) \
> -		return NL_SKIP; \
> -} while (0)
> +
> +#define PARSE_BEACON_CHAN(_attr, _chan) do {		\
> +		r = parse_beacon_hint_chan(tb[_attr],	\
> +					   &_chan);	\
> +		if (r) {				\
> +			fflush(stdout);			\
> +			return NL_SKIP;			\
> +		}					\
> +	} while (0)
> +

Why does that need fflush() here? We'll eventually finish that line, no?

>  	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
>  	struct nlattr *tb[NL80211_ATTR_MAX + 1], *nst;
>  	struct print_event_args *args = arg;
> @@ -349,6 +353,7 @@ static int print_event(struct nl_msg *msg, void *arg)
>  		break;
>  	}
>  
> +	fflush(stdout);
>  	return NL_SKIP;
>  #undef PARSE_BEACON_CHAN

This I'll apply.

> @@ -369,8 +374,8 @@ static int wait_event(struct nl_msg *msg, void *arg)
>  	for (i = 0; i < wait->n_cmds; i++) {
>  		if (gnlh->cmd == wait->cmds[i]) {
>  			wait->cmd = gnlh->cmd;
> -		if (wait->pargs)
> -			print_event(msg, wait->pargs);
> +			if (wait->pargs)
> +				print_event(msg, wait->pargs);

And this is an unrelated patch.

johannes


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

* Re: [PATCH] iw:  Flush stdout when printing events.
  2010-09-29  6:59 ` Johannes Berg
@ 2010-09-29 20:21   ` Ben Greear
  2010-09-29 20:29     ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Greear @ 2010-09-29 20:21 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On 09/28/2010 11:59 PM, Johannes Berg wrote:
> On Tue, 2010-09-28 at 17:30 -0700, greearb@candelatech.com wrote:
>
>> -#define PARSE_BEACON_CHAN(_attr, _chan) do { \
>> -	r = parse_beacon_hint_chan(tb[_attr], \
>> -				&_chan); \
>> -	if (r) \
>> -		return NL_SKIP; \
>> -} while (0)
>> +
>> +#define PARSE_BEACON_CHAN(_attr, _chan) do {		\
>> +		r = parse_beacon_hint_chan(tb[_attr],	\
>> +					&_chan);	\
>> +		if (r) {				\
>> +			fflush(stdout);			\
>> +			return NL_SKIP;			\
>> +		}					\
>> +	} while (0)
>> +
>
> Why does that need fflush() here? We'll eventually finish that line, no?

This returns from the print_event method, so I assume it should
flush.  If it finishes the line, I'm not sure where.

Either way, thanks for taking the other change.

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


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

* Re: [PATCH] iw:  Flush stdout when printing events.
  2010-09-29 20:21   ` Ben Greear
@ 2010-09-29 20:29     ` Johannes Berg
  2010-09-29 20:33       ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2010-09-29 20:29 UTC (permalink / raw)
  To: Ben Greear; +Cc: linux-wireless

On Wed, 2010-09-29 at 13:21 -0700, Ben Greear wrote:
> On 09/28/2010 11:59 PM, Johannes Berg wrote:
> > On Tue, 2010-09-28 at 17:30 -0700, greearb@candelatech.com wrote:
> >
> >> -#define PARSE_BEACON_CHAN(_attr, _chan) do { \
> >> -	r = parse_beacon_hint_chan(tb[_attr], \
> >> -				&_chan); \
> >> -	if (r) \
> >> -		return NL_SKIP; \
> >> -} while (0)
> >> +
> >> +#define PARSE_BEACON_CHAN(_attr, _chan) do {		\
> >> +		r = parse_beacon_hint_chan(tb[_attr],	\
> >> +					&_chan);	\
> >> +		if (r) {				\
> >> +			fflush(stdout);			\
> >> +			return NL_SKIP;			\
> >> +		}					\
> >> +	} while (0)
> >> +
> >
> > Why does that need fflush() here? We'll eventually finish that line, no?
> 
> This returns from the print_event method, so I assume it should
> flush.  If it finishes the line, I'm not sure where.

Oh, you're right, I'll apply this too, and then I'll have done your
three changes in three changesets, heh... oh well :)

johannes


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

* Re: [PATCH] iw:  Flush stdout when printing events.
  2010-09-29 20:29     ` Johannes Berg
@ 2010-09-29 20:33       ` Johannes Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2010-09-29 20:33 UTC (permalink / raw)
  To: Ben Greear; +Cc: linux-wireless

On Wed, 2010-09-29 at 22:29 +0200, Johannes Berg wrote:

> > >> -#define PARSE_BEACON_CHAN(_attr, _chan) do { \
> > >> -	r = parse_beacon_hint_chan(tb[_attr], \
> > >> -				&_chan); \
> > >> -	if (r) \
> > >> -		return NL_SKIP; \
> > >> -} while (0)
> > >> +
> > >> +#define PARSE_BEACON_CHAN(_attr, _chan) do {		\
> > >> +		r = parse_beacon_hint_chan(tb[_attr],	\
> > >> +					&_chan);	\
> > >> +		if (r) {				\
> > >> +			fflush(stdout);			\
> > >> +			return NL_SKIP;			\
> > >> +		}					\
> > >> +	} while (0)
> > >> +
> > >
> > > Why does that need fflush() here? We'll eventually finish that line, no?
> > 
> > This returns from the print_event method, so I assume it should
> > flush.  If it finishes the line, I'm not sure where.
> 
> Oh, you're right, I'll apply this too, and then I'll have done your
> three changes in three changesets, heh... oh well :)

Actually, I just got rid of the macro instead.

johannes


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

end of thread, other threads:[~2010-09-29 20:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-29  0:30 [PATCH] iw: Flush stdout when printing events greearb
2010-09-29  6:59 ` Johannes Berg
2010-09-29 20:21   ` Ben Greear
2010-09-29 20:29     ` Johannes Berg
2010-09-29 20:33       ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).