]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - misc/nstat.c
Update kernel headers
[mirror_iproute2.git] / misc / nstat.c
index 433a1f483be3fecf5e56b988b1ca40ae2af45004..653580eae0603327ea654510ae1f23a79578c1fe 100644 (file)
@@ -37,7 +37,6 @@ int reset_history;
 int ignore_history;
 int no_output;
 int json_output;
-int pretty;
 int no_update;
 int scan_interval;
 int time_constant;
@@ -178,11 +177,13 @@ static int count_spaces(const char *line)
 
 static void load_ugly_table(FILE *fp)
 {
-       char buf[2048];
+       char *buf = NULL;
+       size_t buflen = 0;
+       ssize_t nread;
        struct nstat_ent *db = NULL;
        struct nstat_ent *n;
 
-       while (fgets(buf, sizeof(buf), fp) != NULL) {
+       while ((nread = getline(&buf, &buflen, fp)) != -1) {
                char idbuf[4096];
                int  off;
                char *p;
@@ -219,7 +220,8 @@ static void load_ugly_table(FILE *fp)
                        p = next;
                }
                n = db;
-               if (fgets(buf, sizeof(buf), fp) == NULL)
+               nread = getline(&buf, &buflen, fp);
+               if (nread == -1)
                        abort();
                count2 = count_spaces(buf);
                if (count2 > count1)
@@ -238,6 +240,7 @@ static void load_ugly_table(FILE *fp)
                                n = n->next;
                } while (p > buf + off + 2);
        }
+       free(buf);
 
        while (db) {
                n = db;