Skip to content

Commit e308088

Browse files
cjihrigaduh95
authored andcommitted
sqlite: fix coverity warnings related to backup()
This commit fixes several coverity warnings related to the recently landed backup() API. PR-URL: #56961 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent cf81f09 commit e308088

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/node_sqlite.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ class BackupJob : public ThreadPoolWork {
172172
env_(env),
173173
source_(source),
174174
pages_(pages),
175-
source_db_(source_db),
176-
destination_name_(destination_name),
177-
dest_db_(dest_db) {
175+
source_db_(std::move(source_db)),
176+
destination_name_(std::move(destination_name)),
177+
dest_db_(std::move(dest_db)) {
178178
resolver_.Reset(env->isolate(), resolver);
179179
progressFunc_.Reset(env->isolate(), progressFunc);
180180
}
@@ -315,7 +315,7 @@ class BackupJob : public ThreadPoolWork {
315315
sqlite3* dest_ = nullptr;
316316
sqlite3_backup* backup_ = nullptr;
317317
int pages_;
318-
int backup_status_;
318+
int backup_status_ = SQLITE_OK;
319319
std::string source_db_;
320320
std::string destination_name_;
321321
std::string dest_db_;
@@ -1145,8 +1145,14 @@ void Backup(const FunctionCallbackInfo<Value>& args) {
11451145

11461146
args.GetReturnValue().Set(resolver->GetPromise());
11471147

1148-
BackupJob* job = new BackupJob(
1149-
env, db, resolver, source_db, *dest_path, dest_db, rate, progressFunc);
1148+
BackupJob* job = new BackupJob(env,
1149+
db,
1150+
resolver,
1151+
std::move(source_db),
1152+
*dest_path,
1153+
std::move(dest_db),
1154+
rate,
1155+
progressFunc);
11501156
db->AddBackup(job);
11511157
job->ScheduleBackup();
11521158
}

0 commit comments

Comments
 (0)