From 87a7aec46bf4678a7f69ffc1d1c798aecfa555fb Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 23 Jun 2011 16:35:08 +0000 Subject: [PATCH] tiny rewrite, typefix, don't compare EOF with a char --- ChangeLog | 4 ++++ src/frontend/com_sysinfo.c | 26 +++++++++++--------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 616c18d9c..f2f2ef500 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-06-23 Robert Larice + * src/frontend/com_sysinfo.c : + tiny rewrite, typefix, don't compare EOF with a char + 2011-06-23 Holger Vogt * measure.c: another try to obtain correct vector handling diff --git a/src/frontend/com_sysinfo.c b/src/frontend/com_sysinfo.c index 912c65b8a..6a7fde4c0 100644 --- a/src/frontend/com_sysinfo.c +++ b/src/frontend/com_sysinfo.c @@ -214,17 +214,14 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) { /* get kernel version string */ file = fopen("/proc/version", "rb"); if(file != NULL) { - tInt size = 0; - char buf; + size_t size; /* read bytes and find end of file */ - buf = fgetc(file); - while(buf != EOF) { - size++; - buf = fgetc(file); - } + for(size=0; ; size++) + if(EOF == fgetc(file)) + break; - info->osName = (char*) malloc((size) * sizeof(char)); + info->osName = (char*) malloc(size * sizeof(char)); rewind(file); fread(info->osName, sizeof(char), size, file); fclose(file); @@ -238,15 +235,14 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) { /* get cpu information */ file = fopen("/proc/cpuinfo", "rb"); if(file != NULL) { - tInt size = 0; - char buf, *inStr; + size_t size; + char *inStr; /* read bytes and find end of file */ - buf = fgetc(file); - while(buf != EOF) { - size++; - buf = fgetc(file); - } + for(size=0; ; size++) + if(EOF == fgetc(file)) + break; + /* get complete string */ inStr = (char*) malloc((size+1) * sizeof(char)); rewind(file);