clang-tidy: modernize-make-unique

This commit is contained in:
Peter Johnson
2020-12-28 09:43:14 -08:00
parent 6131f4e32b
commit 29c7da5f1a
3 changed files with 9 additions and 5 deletions

View File

@@ -6,6 +6,7 @@
#include <algorithm>
#include <cstring>
#include <memory>
#include <wpi/json.h>
#include <wpi/timestamp.h>
@@ -423,7 +424,7 @@ std::unique_ptr<Image> SourceImpl::AllocImage(
// if nothing found, allocate a new buffer
if (found < 0) {
image.reset(new Image{size});
image = std::make_unique<Image>(size);
} else {
image = std::move(m_imagesAvail[found]);
}

View File

@@ -20,6 +20,7 @@
#include <unistd.h>
#include <algorithm>
#include <memory>
#include <wpi/FileSystem.h>
#include <wpi/MemAlloc.h>
@@ -378,8 +379,8 @@ void UsbCameraImpl::CameraThreadMain() {
close(notify_fd);
notify_fd = -1;
} else {
notify_is.reset(new wpi::raw_fd_istream{
notify_fd, true, sizeof(struct inotify_event) + NAME_MAX + 1});
notify_is = std::make_unique<wpi::raw_fd_istream>(
notify_fd, true, sizeof(struct inotify_event) + NAME_MAX + 1);
}
}
bool notified = (notify_fd < 0); // treat as always notified if cannot notify

View File

@@ -5,6 +5,7 @@
#include "frc/SPI.h"
#include <cstring>
#include <memory>
#include <utility>
#include <hal/FRCUsageReporting.h>
@@ -351,8 +352,9 @@ void SPI::InitAccumulator(units::second_t period, int cmd, int xferSize,
SetAutoTransmitData(cmdBytes, xferSize - 4);
StartAutoRate(period);
m_accum.reset(new Accumulator(m_port, xferSize, validMask, validValue,
dataShift, dataSize, isSigned, bigEndian));
m_accum =
std::make_unique<Accumulator>(m_port, xferSize, validMask, validValue,
dataShift, dataSize, isSigned, bigEndian);
m_accum->m_notifier.StartPeriodic(period * kAccumulateDepth / 2);
}