diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2014-02-26 14:14:33 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2014-02-26 14:14:33 +0100 |
commit | 35400b74a777675ba9f5ffd85b68feb705cd934b (patch) | |
tree | 1c763de1e8f3f251dba89e898f6dd6a1591a7f3e /ifpps.c | |
parent | c979433abb11a67d82c0b345ef28b38907ba6d9e (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.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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); |