Rudolf Mayerhofer <rm(a)eightyfive.net> writes:
+/*********************************************************************** + * Several methods to retrieve data from SysFS (/sys) + * used to retrieve cached_lpi in fill_cpu_info() + */ +static int sysfs_cpu_exists(int cpu) +{ + char buf[256]; + + sprintf(buf, "/sys/devices/system/cpu/cpu%d", cpu); + return access(buf, F_OK) == 0; +} + +static int sysfs_cpucache_exists(int cpu, int cache) +{ + char buf[256]; + + sprintf(buf, "/sys/devices/system/cpu/cpu%d/cache/index%d", cpu, cache); + return access(buf, F_OK) == 0; +} + +static int sysfs_numanode_exists(int node) +{ + char buf[256]; + + sprintf(buf, "/sys/devices/system/node/node%d", node); + return access(buf, F_OK) == 0; +}
Don't do that sort of thing. You should handle failures to open the files at the point where you need them instead of doing redundant checks. -- Alexandre Julliard julliard(a)winehq.org