[2/3] ntdll: Implement NtQuerySystemInformation/SystemLogicalProcessorInformation (try 5)
Rudolf Mayerhofer
rm at eightyfive.net
Fri Oct 8 07:36:53 CDT 2010
On Friday 08 October 2010 14:26:28 Alexandre Julliard wrote:
> Rudolf Mayerhofer <rm at 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.
That's not the case here, these checks are simply to find out if a cpu,cpu
cache or numa node index exists in SysFS. It just makes no sense to try to
parse all of the stuff for a specific cpu index if it does not exist in the first
place and this is the check for that (it's done the same way as lscpu from
util-linux-ng does it).
All the parsing functions have their own error handling as well.
More information about the wine-devel
mailing list