iw: Flush stdout when printing events.
PATCH 1/1 iw: Flush stdout when printing events.
From: Ben Greear <[email protected]>
This lets one pipe output of iw event properly.
---
:100644 100644 129db1a... 60bafc5... M event.c
event.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-)
event.c +13 -8
@@ -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); } }
Signature · 1 line
1.5.4.3
Quoted 6 lines · On Tue, 2010-09-28 at 17:30 -0700, [email protected] wrote:
event.c +0
-6-#define PARSE_BEACON_CHAN (_attr, _chan) do { \ - r = parse_beacon_hint_chan(tb[_attr], \ - &_chan); \ - if (r) \ - return NL_SKIP; \ -} while (0)
event.c static void parse_cqm_event(struct nlattr *tb) · line 142
Quoted 10 lines
event.c +10
-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?
event.c static int print_event(struct nl_msg *msg, void *arg) · line 358
Quoted 10 lines
event.c +1
-0struct 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.
event.c static int wait_event(struct nl_msg *msg, void *arg) · line 378
Quoted 8 lines
event.c +2
-2@@ -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
Quoted 12 lines · Johannes Berg
Quoted 10 lines · On Tue, 2010-09-28 at 17:30 -0700, [email protected] wrote:
event.c +4
-6-#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); \
Quoted 8 lines
event.c static void parse_cqm_event(struct nlattr *tb) · line 142
Quoted 6 lines
event.c +6
-0+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
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 22 lines · Ben Greear
Quoted 12 lines · Johannes Berg
Quoted 10 lines · On Tue, 2010-09-28 at 17:30 -0700, [email protected] wrote:
event.c +4
-6-#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); \Quoted 8 lines
event.c static void parse_cqm_event(struct nlattr *tb) · line 142
Quoted 6 lines
event.c +6
-0+if (r) { \ +fflush (stdout); \ +return NL_SKIP ; \ + } \ + }while (0 ) +Why does that need
fflush()here? We'll eventually finish that line, no?
Quoted 2 lines
This returns from the
print_eventmethod, 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
Quoted 19 lines · Johannes Berg
Quoted 19 lines
Quoted 18 lines
Quoted 6 lines
event.c +0
-6-#define PARSE_BEACON_CHAN (_attr, _chan) do { \ - r = parse_beacon_hint_chan(tb[_attr], \ - &_chan); \ - if (r) \ - return NL_SKIP; \ -} while (0)event.c static void parse_cqm_event(struct nlattr *tb) · line 142
Quoted 10 lines
event.c +10
-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?
Quoted 5 lines
Quoted 2 lines
This returns from the
print_eventmethod, 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