cpupower tools: Remove brace expansion from clean target

The clean targets from the cpupower tools' Makefiles use brace expansion to
remove some generated files. However, the default shells on many systems do
not support this feature resulting in some generated files not being removed
by clean.

Signed-off-by: Palmer Cox <p@lmercox.com>
Reviewed-by: Thomas Renninger <trenn@suse.de>
cpupower tools: Update .gitignore for files created in the debug directories

The files generated by the Makefiles in the debug directories aren't listed
in the .gitignore file in the root of the cpupower tool which causes these
files to show up in the output of 'git status'.

Signed-off-by: Palmer Cox <p@lmercox.com>
Reviewed-by: Thomas Renninger <trenn@suse.de>
cpupower tools: Fix minor warnings

Fix minor warnings reported with GCC 4.6:
* The sysfs_write_file function is unused - remove it.
* The pr_mon_len in the print_header function is unsed - remove it.

Signed-off-by: Palmer Cox <p@lmercox.com>
Reviewed-by: Thomas Renninger <trenn@suse.de>
cpupower tools: Fix issues with sysfs_topology_read_file

Fix a variety of issues with sysfs_topology_read_file:
* The return value of sysfs_topology_read_file function was not properly
  being checked for failure.
* The function was reading int valued sysfs variables and then returning
  their value. So, even if a function was trying to check the return value
  of this function, a caller would not be able to tell an failure code apart
  from reading a negative value. This also conflicted with the comment on the
  function which said that a return value of 0 indicated success.
* The function was parsing int valued sysfs values with strtoul instead of
  strtol.
* The function was non-static even though it was only used in the
  file it was declared in.

Signed-off-by: Palmer Cox <p@lmercox.com>
Reviewed-by: Thomas Renninger <trenn@suse.de>
cpupower tools: Fix malloc of cpu_info structure

The cpu_info member of cpupower_topology was being declared as an unnamed
structure. This member was then being malloced using the size of the
parent cpupower_topology * the number of cpus. This works
because cpu_info is smaller than cpupower_topology. However, there is
no guarantee that will always be the case. Making cpu_info its own
top level structure (named cpuid_core_info) allows for mallocing the actual
size of this structure. This also lets us get rid of a redefinition of
the structure in topology.c with slightly different field names.

Signed-off-by: Palmer Cox <p@lmercox.com>
cpupower tools: Fix warning and a bug with the cpu package count

The pkgs member of cpupower_topology is being used as the number of
cpu packages. As the comment in get_cpu_topology notes, the package ids
are not guaranteed to be contiguous. So, simply setting pkgs to the value
of the highest physical_package_id doesn't actually provide a count of
the number of cpu packages. Instead, calculate pkgs by setting it to
the number of distinct physical_packge_id values which is pretty easy
to do after the core_info structs are sorted. Calculating pkgs this
way also has the nice benefit of getting rid of a sign comparison warning
that GCC 4.6 was reporting.

Signed-off-by: Palmer Cox <p@lmercox.com>