]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/tc_monitor.c
tc, ip: more Makefile updates for LIBMNL
[mirror_iproute2.git] / tc / tc_monitor.c
index 097068e91e51f865a3f9a5baa0c0c381a1e74198..83142cb21f5440c00b8d5dc651e6a3303ec237b1 100644 (file)
@@ -39,7 +39,7 @@ static int accept_tcmsg(const struct sockaddr_nl *who,
                        struct rtnl_ctrl_data *ctrl,
                        struct nlmsghdr *n, void *arg)
 {
-       FILE *fp = (FILE*)arg;
+       FILE *fp = (FILE *)arg;
 
        if (timestamp)
                print_timestamp(fp);
@@ -73,7 +73,7 @@ int do_tcmonitor(int argc, char **argv)
 {
        struct rtnl_handle rth;
        char *file = NULL;
-       unsigned groups = nl_mgrp(RTNLGRP_TC);
+       unsigned int groups = nl_mgrp(RTNLGRP_TC);
 
        while (argc > 0) {
                if (matches(*argv, "file") == 0) {
@@ -91,13 +91,17 @@ int do_tcmonitor(int argc, char **argv)
        }
 
        if (file) {
-               FILE *fp;
-               fp = fopen(file, "r");
+               FILE *fp = fopen(file, "r");
+               int ret;
+
                if (fp == NULL) {
                        perror("Cannot fopen");
                        exit(-1);
                }
-               return rtnl_from_file(fp, accept_tcmsg, (void*)stdout);
+
+               ret = rtnl_from_file(fp, accept_tcmsg, stdout);
+               fclose(fp);
+               return ret;
        }
 
        if (rtnl_open(&rth, groups) < 0)
@@ -105,7 +109,7 @@ int do_tcmonitor(int argc, char **argv)
 
        ll_init_map(&rth);
 
-       if (rtnl_listen(&rth, accept_tcmsg, (void*)stdout) < 0) {
+       if (rtnl_listen(&rth, accept_tcmsg, (void *)stdout) < 0) {
                rtnl_close(&rth);
                exit(2);
        }