Refactor handling CPUInfo array

It was found that sometimes peci-pcie crashes with out-of-range read of
cpuInfo vector. This happens on start scan when for some reasons system
failed to initialize vector.

While technically enough to add guard near the line
	scanPCIeDevice(io, objServer, cpuInfo, 0, 0, 0);
it is better to refactor whole related code.

This commit introduces following code optimizations:
* Merge getClientAddrMap and getCPUBusNums to one function getCPUBusMap
  since they both always called together and do same work: fill cpuInfo
  vector. Resulting getCPUBusMap function now return error if no CPUs
  discovered.
* probePCIeDevice doesn't really need cpuInfo vector, it's fine with
  just single CPU address.
* scanPCIeDevice now the only function which read from cpuInfo and it
  verify index before and return if it is not valid.

Tested: ensure no functional changes, no crash if cpuInfo vector empty

Signed-off-by: Andrei Kartashev <a.kartashev@yadro.com>
Change-Id: Ie6bab4e844670ceecd515728f43f7d22efa1aed6
1 file changed
tree: 19cf740796bebe8648c8fc6be3205759bf6f0376
  1. include/
  2. service_files/
  3. src/
  4. utils/
  5. .clang-format
  6. CMakeLists.txt
  7. LICENSE
  8. MAINTAINERS
  9. README.md
README.md

peci-pcie

The peci-pcie application uses the CPU PECI interface to get PCIe Device information for the system and shares it on D-Bus. The information from D-Bus is used by bmcweb to populate the PCIe Device resources in Redfish.