summaryrefslogtreecommitdiff
path: root/ifpps.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-02-26 14:14:33 +0100
committerTobias Klauser <tklauser@distanz.ch>2014-02-26 14:14:33 +0100
commit35400b74a777675ba9f5ffd85b68feb705cd934b (patch)
tree1c763de1e8f3f251dba89e898f6dd6a1591a7f3e /ifpps.c
parentc979433abb11a67d82c0b345ef28b38907ba6d9e (diff)
ifpps: Reorder buffer allocation and file opening in stats_proc_interrupts
We don't need the file open to allocate the buffer so open it just before it's used for the first time. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ifpps.c')
-rw-r--r--ifpps.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ifpps.c b/ifpps.c
index 6c0387b..6f50bed 100644
--- a/ifpps.c
+++ b/ifpps.c
@@ -273,13 +273,13 @@ static int stats_proc_interrupts(char *ifname, struct ifstat *stats)
struct ethtool_drvinfo drvinf;
FILE *fp;
- fp = fopen("/proc/interrupts", "r");
- if (!fp)
- panic("Cannot open /proc/interrupts!\n");
-
cpus = get_number_cpus();
buff_len = cpus * 128;
buff = xmalloc(buff_len);
+
+ fp = fopen("/proc/interrupts", "r");
+ if (!fp)
+ panic("Cannot open /proc/interrupts!\n");
retry:
fseek(fp, 0, SEEK_SET);
memset(buff, 0, buff_len);