]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - event.c
iw: don't use NULL pointer in nla_nest_end()
[thirdparty/iw.git] / event.c
diff --git a/event.c b/event.c
index f73e078d4aea80109b4f986e6ec29f05587865ba..896f03ab7636a49b3e477581fa3744175437e27c 100644 (file)
--- a/event.c
+++ b/event.c
@@ -45,12 +45,14 @@ static void print_frame(struct print_event_args *args, struct nlattr *attr)
 {
        uint8_t *frame;
        size_t len;
-       int i;
+       unsigned int i;
        char macbuf[6*3];
        uint16_t tmp;
 
-       if (!attr)
+       if (!attr) {
                printf(" [no frame]");
+               return;
+       }
 
        frame = nla_data(attr);
        len = nla_len(attr);
@@ -703,14 +705,15 @@ __u32 __do_listen_events(struct nl80211_state *state,
 
        /* no sequence checking for multicast messages */
        nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
+       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, NULL);
 
        if (n_waits && waits) {
                wait_ev.cmds = waits;
                wait_ev.n_cmds = n_waits;
                wait_ev.pargs = args;
-               nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, wait_event, &wait_ev);
+               register_handler(wait_event, &wait_ev);
        } else
-               nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_event, args);
+               register_handler(print_event, args);
 
        wait_ev.cmd = 0;
 
@@ -735,7 +738,6 @@ __u32 listen_events(struct nl80211_state *state,
 }
 
 static int print_events(struct nl80211_state *state,
-                       struct nl_cb *cb,
                        struct nl_msg *msg,
                        int argc, char **argv,
                        enum id_input id)
@@ -773,7 +775,7 @@ static int print_events(struct nl80211_state *state,
 
        return __do_listen_events(state, 0, NULL, &args);
 }
-TOPLEVEL(event, "[-t] [-r] [-f]", 0, 0, CIB_NONE, print_events,
+TOPLEVEL(event, "[-t|-r] [-f]", 0, 0, CIB_NONE, print_events,
        "Monitor events from the kernel.\n"
        "-t - print timestamp\n"
        "-r - print relative timstamp\n"