From 8f1a1a433e85f8772f0bb37f4028c70aa6a5942f Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 8 Feb 2025 13:20:04 -0500 Subject: [PATCH] sqlite: fix coverity warnings related to backup() This commit fixes several coverity warnings related to the recently landed backup() API. --- src/node_sqlite.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index 58cd643328b783..ff2c8a05865529 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -171,9 +171,9 @@ class BackupJob : public ThreadPoolWork { env_(env), source_(source), pages_(pages), - source_db_(source_db), - destination_name_(destination_name), - dest_db_(dest_db) { + source_db_(std::move(source_db)), + destination_name_(std::move(destination_name)), + dest_db_(std::move(dest_db)) { resolver_.Reset(env->isolate(), resolver); progressFunc_.Reset(env->isolate(), progressFunc); } @@ -314,7 +314,7 @@ class BackupJob : public ThreadPoolWork { sqlite3* dest_ = nullptr; sqlite3_backup* backup_ = nullptr; int pages_; - int backup_status_; + int backup_status_ = SQLITE_OK; std::string source_db_; std::string destination_name_; std::string dest_db_; @@ -1078,8 +1078,14 @@ void Backup(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(resolver->GetPromise()); - BackupJob* job = new BackupJob( - env, db, resolver, source_db, *dest_path, dest_db, rate, progressFunc); + BackupJob* job = new BackupJob(env, + db, + resolver, + std::move(source_db), + *dest_path, + std::move(dest_db), + rate, + progressFunc); db->AddBackup(job); job->ScheduleBackup(); }