From 35400b74a777675ba9f5ffd85b68feb705cd934b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 26 Feb 2014 14:14:33 +0100 Subject: [PATCH] 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 --- ifpps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ifpps.c b/ifpps.c index 6c0387b4..6f50bede 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); -- 2.11.4.GIT