refactor: run clang-tidy (#20231)

* refactor: clang-tidy modernize-use-nullptr

* refactor: clang-tidy modernize-use-equals-default

* refactor: clang-tidy modernize-make-unique

* refactor: omit nullptr arg from unique_ptr.reset()

As per comment by @miniak
This commit is contained in:
Charles Kerr 2019-09-16 18:12:00 -04:00 committed by GitHub
parent 660e566201
commit 2b316f3843
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
93 changed files with 261 additions and 223 deletions

View file

@ -4,13 +4,15 @@
#include "shell/common/api/locker.h"
#include <memory>
namespace mate {
Locker::Locker(v8::Isolate* isolate) {
if (IsBrowserProcess())
locker_.reset(new v8::Locker(isolate));
locker_ = std::make_unique<v8::Locker>(isolate);
}
Locker::~Locker() {}
Locker::~Locker() = default;
} // namespace mate

View file

@ -32,7 +32,7 @@ RemoteCallbackFreer::RemoteCallbackFreer(v8::Isolate* isolate,
context_id_(context_id),
object_id_(object_id) {}
RemoteCallbackFreer::~RemoteCallbackFreer() {}
RemoteCallbackFreer::~RemoteCallbackFreer() = default;
void RemoteCallbackFreer::RunDestructor() {
auto* channel = "ELECTRON_RENDERER_RELEASE_CALLBACK";

View file

@ -57,7 +57,7 @@ RemoteObjectFreer::RemoteObjectFreer(v8::Isolate* isolate,
}
}
RemoteObjectFreer::~RemoteObjectFreer() {}
RemoteObjectFreer::~RemoteObjectFreer() = default;
void RemoteObjectFreer::RunDestructor() {
content::RenderFrame* render_frame =

View file

@ -11,7 +11,7 @@
namespace asar {
ScopedTemporaryFile::ScopedTemporaryFile() {}
ScopedTemporaryFile::ScopedTemporaryFile() = default;
ScopedTemporaryFile::~ScopedTemporaryFile() {
if (!path_.empty()) {

View file

@ -40,7 +40,7 @@ CrashReporter::CrashReporter() {
// process_type_ will be empty for browser process
}
CrashReporter::~CrashReporter() {}
CrashReporter::~CrashReporter() = default;
bool CrashReporter::IsInitialized() {
return is_initialized_;

View file

@ -8,6 +8,8 @@
#include <sys/time.h>
#include <unistd.h>
#include <memory>
#include <string>
#include "base/debug/crash_logging.h"
@ -38,7 +40,7 @@ static const off_t kMaxMinidumpFileSize = 1258291;
CrashReporterLinux::CrashReporterLinux() : pid_(getpid()) {
// Set the base process start time value.
struct timeval tv;
if (!gettimeofday(&tv, NULL)) {
if (!gettimeofday(&tv, nullptr)) {
uint64_t ret = tv.tv_sec;
ret *= 1000;
ret += tv.tv_usec / 1000;
@ -49,7 +51,7 @@ CrashReporterLinux::CrashReporterLinux() : pid_(getpid()) {
base::SetLinuxDistro(base::GetLinuxDistro());
}
CrashReporterLinux::~CrashReporterLinux() {}
CrashReporterLinux::~CrashReporterLinux() = default;
void CrashReporterLinux::Init(const std::string& product_name,
const std::string& company_name,
@ -62,7 +64,7 @@ void CrashReporterLinux::Init(const std::string& product_name,
upload_url_ = submit_url;
upload_to_server_ = upload_to_server;
crash_keys_.reset(new CrashKeyStorage());
crash_keys_ = std::make_unique<CrashKeyStorage>();
for (StringMap::const_iterator iter = upload_parameters_.begin();
iter != upload_parameters_.end(); ++iter)
crash_keys_->SetKeyValue(iter->first.c_str(), iter->second.c_str());
@ -91,10 +93,10 @@ void CrashReporterLinux::EnableCrashDumping(const base::FilePath& crashes_dir) {
MinidumpDescriptor minidump_descriptor(crashes_dir.value());
minidump_descriptor.set_size_limit(kMaxMinidumpFileSize);
breakpad_.reset(new ExceptionHandler(minidump_descriptor, NULL, CrashDone,
this,
true, // Install handlers.
-1));
breakpad_ = std::make_unique<ExceptionHandler>(minidump_descriptor, nullptr,
CrashDone, this,
true, // Install handlers.
-1);
}
bool CrashReporterLinux::CrashDone(const MinidumpDescriptor& minidump,

View file

@ -166,7 +166,7 @@ class MimeWriter {
MimeWriter::MimeWriter(int fd, const char* const mime_boundary)
: fd_(fd), mime_boundary_(mime_boundary) {}
MimeWriter::~MimeWriter() {}
MimeWriter::~MimeWriter() = default;
void MimeWriter::AddBoundary() {
AddString(mime_boundary_);
@ -349,12 +349,12 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
static const char kWgetBinary[] = "/usr/bin/wget";
const char* args[] = {
kWgetBinary, header, post_file, info.upload_url,
kWgetBinary, header, post_file, info.upload_url,
"--timeout=60", // Set a timeout so we don't hang forever.
"--tries=1", // Don't retry if the upload fails.
"--quiet", // Be silent.
"-O", // output reply to /dev/null.
"/dev/fd/3", NULL,
"/dev/fd/3", nullptr,
};
static const char msg[] =
"Cannot upload crash dump: cannot exec "
@ -437,7 +437,7 @@ void HandleCrashReportId(const char* buf,
// Write crash dump id to crash log as: seconds_since_epoch,crash_id
struct kernel_timeval tv;
if (!sys_gettimeofday(&tv, NULL)) {
if (!sys_gettimeofday(&tv, nullptr)) {
uint64_t time = kernel_timeval_to_ms(&tv) / 1000;
char time_str[kUint64StringSize];
const unsigned time_len = my_uint64_len(time);
@ -465,7 +465,7 @@ void HandleCrashDump(const BreakpadInfo& info) {
size_t dump_size;
uint8_t* dump_data;
google_breakpad::PageAllocator allocator;
const char* exe_buf = NULL;
const char* exe_buf = nullptr;
if (info.fd != -1) {
// Dump is provided with an open FD.
@ -614,7 +614,7 @@ void HandleCrashDump(const BreakpadInfo& info) {
if (info.process_start_time > 0) {
struct kernel_timeval tv;
if (!sys_gettimeofday(&tv, NULL)) {
if (!sys_gettimeofday(&tv, nullptr)) {
uint64_t time = kernel_timeval_to_ms(&tv);
if (time > info.process_start_time) {
time -= info.process_start_time;
@ -723,7 +723,7 @@ void HandleCrashDump(const BreakpadInfo& info) {
WaitForCrashReportUploadProcess(fds[0], kCrashIdLength, id_buf);
HandleCrashReportId(id_buf, bytes_read, kCrashIdLength);
if (sys_waitpid(upload_child, NULL, WNOHANG) == 0) {
if (sys_waitpid(upload_child, nullptr, WNOHANG) == 0) {
// Upload process is still around, kill it.
sys_kill(upload_child, SIGKILL);
}
@ -739,7 +739,7 @@ void HandleCrashDump(const BreakpadInfo& info) {
// Main browser process.
if (child <= 0)
return;
(void)HANDLE_EINTR(sys_waitpid(child, NULL, 0));
(void)HANDLE_EINTR(sys_waitpid(child, nullptr, 0));
}
size_t WriteLog(const char* buf, size_t nbytes) {

View file

@ -102,10 +102,9 @@ class RefCountedGlobal
SafeV8Function::SafeV8Function(v8::Isolate* isolate, v8::Local<v8::Value> value)
: v8_function_(new RefCountedGlobal<v8::Function>(isolate, value)) {}
SafeV8Function::SafeV8Function(const SafeV8Function& other)
: v8_function_(other.v8_function_) {}
SafeV8Function::SafeV8Function(const SafeV8Function& other) = default;
SafeV8Function::~SafeV8Function() {}
SafeV8Function::~SafeV8Function() = default;
bool SafeV8Function::IsAlive() const {
return v8_function_.get() && v8_function_->IsAlive();

View file

@ -106,10 +106,9 @@ class RefCountedGlobal
SafeV8Function::SafeV8Function(v8::Isolate* isolate, v8::Local<v8::Value> value)
: v8_function_(new RefCountedGlobal<v8::Function>(isolate, value)) {}
SafeV8Function::SafeV8Function(const SafeV8Function& other)
: v8_function_(other.v8_function_) {}
SafeV8Function::SafeV8Function(const SafeV8Function& other) = default;
SafeV8Function::~SafeV8Function() {}
SafeV8Function::~SafeV8Function() = default;
bool SafeV8Function::IsAlive() const {
return v8_function_.get() && v8_function_->IsAlive();

View file

@ -122,7 +122,7 @@ class V8ValueConverter::ScopedUniquenessGuard {
DISALLOW_COPY_AND_ASSIGN(ScopedUniquenessGuard);
};
V8ValueConverter::V8ValueConverter() {}
V8ValueConverter::V8ValueConverter() = default;
void V8ValueConverter::SetRegExpAllowed(bool val) {
reg_exp_allowed_ = val;
@ -386,7 +386,7 @@ std::unique_ptr<base::Value> V8ValueConverter::FromV8Array(
// that context, but change back after val is converted.
if (!val->CreationContext().IsEmpty() &&
val->CreationContext() != isolate->GetCurrentContext())
scope.reset(new v8::Context::Scope(val->CreationContext()));
scope = std::make_unique<v8::Context::Scope>(val->CreationContext());
std::unique_ptr<base::ListValue> result(new base::ListValue());
@ -442,7 +442,7 @@ std::unique_ptr<base::Value> V8ValueConverter::FromV8Object(
// that context, but change back after val is converted.
if (!val->CreationContext().IsEmpty() &&
val->CreationContext() != isolate->GetCurrentContext())
scope.reset(new v8::Context::Scope(val->CreationContext()));
scope = std::make_unique<v8::Context::Scope>(val->CreationContext());
auto result = std::make_unique<base::DictionaryValue>();
v8::Local<v8::Array> property_names;

View file

@ -17,7 +17,7 @@ NodeBindingsLinux::NodeBindingsLinux(BrowserEnvironment browser_env)
epoll_ctl(epoll_, EPOLL_CTL_ADD, backend_fd, &ev);
}
NodeBindingsLinux::~NodeBindingsLinux() {}
NodeBindingsLinux::~NodeBindingsLinux() = default;
void NodeBindingsLinux::RunMessageLoop() {
// Get notified when libuv's watcher queue changes.