Commit c2123ce0 authored by Trent Begin's avatar Trent Begin Committed by Commit Bot

Make cros_healthd CpuInfo field model_name optional

There are certain arm devices that do not populate the model name of the
CPU in sysfs. This change makes the model_name field optional to reflect
this.

Bug: chromium:1132875
Change-Id: I7f8c814bf77c22cc7f7ca6f482d37f46097a4335
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436383Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
Commit-Queue: Trent Begin <tbegin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812172}
parent 664990eb
...@@ -1057,7 +1057,8 @@ class DeviceStatusCollectorState : public StatusCollectorState { ...@@ -1057,7 +1057,8 @@ class DeviceStatusCollectorState : public StatusCollectorState {
em::CpuInfo* const cpu_info_out = em::CpuInfo* const cpu_info_out =
response_params_.device_status->add_cpu_info(); response_params_.device_status->add_cpu_info();
cpu_info_out->set_model_name(physical_cpu->model_name); if (physical_cpu->model_name)
cpu_info_out->set_model_name(physical_cpu->model_name.value());
cpu_info_out->set_architecture( cpu_info_out->set_architecture(
static_cast<em::CpuInfo::Architecture>(cpu_info->architecture)); static_cast<em::CpuInfo::Architecture>(cpu_info->architecture));
......
...@@ -44,7 +44,7 @@ void PopulateCpuInfo(const healthd::CpuInfo& cpu_info, ...@@ -44,7 +44,7 @@ void PopulateCpuInfo(const healthd::CpuInfo& cpu_info,
// If there is more than one physical cpu on the device, use the name of the // If there is more than one physical cpu on the device, use the name of the
// first CPU. // first CPU.
out_system_info.cpu_model_name = physical_cpus[0]->model_name; out_system_info.cpu_model_name = physical_cpus[0]->model_name.value_or("");
} }
void PopulateVersionInfo(const healthd::SystemInfo& system_info, void PopulateVersionInfo(const healthd::SystemInfo& system_info,
......
...@@ -290,8 +290,8 @@ struct CpuInfo { ...@@ -290,8 +290,8 @@ struct CpuInfo {
// Information related to a particular physical CPU. // Information related to a particular physical CPU.
struct PhysicalCpuInfo { struct PhysicalCpuInfo {
// The CPU model name. // The CPU model name, if available.
string model_name; string? model_name;
// Logical CPUs corresponding to this physical CPU. // Logical CPUs corresponding to this physical CPU.
array<LogicalCpuInfo> logical_cpus; array<LogicalCpuInfo> logical_cpus;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment