Browse Source

tiny rewrite, typefix, don't compare EOF with a char

rlar 15 years ago
parent
commit
87a7aec46b
  1. 4
      ChangeLog
  2. 26
      src/frontend/com_sysinfo.c

4
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 2011-06-23 Holger Vogt
* measure.c: another try to obtain correct vector handling * measure.c: another try to obtain correct vector handling

26
src/frontend/com_sysinfo.c

@ -214,17 +214,14 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) {
/* get kernel version string */ /* get kernel version string */
file = fopen("/proc/version", "rb"); file = fopen("/proc/version", "rb");
if(file != NULL) { if(file != NULL) {
tInt size = 0;
char buf;
size_t size;
/* read bytes and find end of file */ /* 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); rewind(file);
fread(info->osName, sizeof(char), size, file); fread(info->osName, sizeof(char), size, file);
fclose(file); fclose(file);
@ -238,15 +235,14 @@ TesError tesCreateSystemInfo(TesSystemInfo *info) {
/* get cpu information */ /* get cpu information */
file = fopen("/proc/cpuinfo", "rb"); file = fopen("/proc/cpuinfo", "rb");
if(file != NULL) { if(file != NULL) {
tInt size = 0;
char buf, *inStr;
size_t size;
char *inStr;
/* read bytes and find end of file */ /* 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 */ /* get complete string */
inStr = (char*) malloc((size+1) * sizeof(char)); inStr = (char*) malloc((size+1) * sizeof(char));
rewind(file); rewind(file);

Loading…
Cancel
Save