From 29c7da5f1a58c6c69f50b4eaa8b6d41a43c2aad9 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 28 Dec 2020 09:43:14 -0800 Subject: [PATCH] clang-tidy: modernize-make-unique --- cscore/src/main/native/cpp/SourceImpl.cpp | 3 ++- cscore/src/main/native/linux/UsbCameraImpl.cpp | 5 +++-- wpilibc/src/main/native/cpp/SPI.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cscore/src/main/native/cpp/SourceImpl.cpp b/cscore/src/main/native/cpp/SourceImpl.cpp index b764555d9d..b88a1e1a2a 100644 --- a/cscore/src/main/native/cpp/SourceImpl.cpp +++ b/cscore/src/main/native/cpp/SourceImpl.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -423,7 +424,7 @@ std::unique_ptr SourceImpl::AllocImage( // if nothing found, allocate a new buffer if (found < 0) { - image.reset(new Image{size}); + image = std::make_unique(size); } else { image = std::move(m_imagesAvail[found]); } diff --git a/cscore/src/main/native/linux/UsbCameraImpl.cpp b/cscore/src/main/native/linux/UsbCameraImpl.cpp index 4d75984e16..31e5792d18 100644 --- a/cscore/src/main/native/linux/UsbCameraImpl.cpp +++ b/cscore/src/main/native/linux/UsbCameraImpl.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -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( + notify_fd, true, sizeof(struct inotify_event) + NAME_MAX + 1); } } bool notified = (notify_fd < 0); // treat as always notified if cannot notify diff --git a/wpilibc/src/main/native/cpp/SPI.cpp b/wpilibc/src/main/native/cpp/SPI.cpp index 6788beadba..28437cea77 100644 --- a/wpilibc/src/main/native/cpp/SPI.cpp +++ b/wpilibc/src/main/native/cpp/SPI.cpp @@ -5,6 +5,7 @@ #include "frc/SPI.h" #include +#include #include #include @@ -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(m_port, xferSize, validMask, validValue, + dataShift, dataSize, isSigned, bigEndian); m_accum->m_notifier.StartPeriodic(period * kAccumulateDepth / 2); }