Code Health: Use span variant of base::ReadFromFd
The variant which passes a char* + offset is being removed This CL is split from https://crrev.com/c/5168849 This CL was uploaded by git cl split. R=fdoray@chromium.org Bug: 1490484 Change-Id: If2daa9a7664d089147f65fc4c43f57f9f756721d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5179532 Commit-Queue: Francois Pierre Doray <fdoray@chromium.org> Reviewed-by: Francois Pierre Doray <fdoray@chromium.org> Auto-Submit: Austin Sullivan <asully@chromium.org> Cr-Commit-Position: refs/heads/main@{#1245290}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
0d63799185
commit
5c98ac28f2
@ -9,6 +9,7 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/scoped_file.h"
|
||||
@ -115,9 +116,9 @@ EnergyMetricsProviderLinux::CaptureMetrics() {
|
||||
EnergyMetrics energy_metrics = {0};
|
||||
for (const auto& event : events_) {
|
||||
uint64_t absolute_energy;
|
||||
if (!base::ReadFromFD(event.fd.get(),
|
||||
reinterpret_cast<char*>(&absolute_energy),
|
||||
sizeof(absolute_energy))) {
|
||||
if (!base::ReadFromFD(
|
||||
event.fd.get(),
|
||||
base::as_writable_chars(base::make_span(&absolute_energy, 1u)))) {
|
||||
LOG(ERROR) << "Failed to read absolute energy of " << event.metric_type;
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user