From d295ca1d170b9c8cbb41addfc6fda192c3fb7f43 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 17 Aug 2024 22:00:41 +0200 Subject: [PATCH] code cleanup: use std::move() to potentially void copies Found by Coverity. Signed-off-by: Berthold Stoeger --- commands/command.cpp | 4 ++-- core/equipment.cpp | 2 +- core/liquivision.cpp | 2 +- qt-models/cylindermodel.cpp | 4 ++-- qt-models/weightmodel.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/commands/command.cpp b/commands/command.cpp index 8381101bd..162247d75 100644 --- a/commands/command.cpp +++ b/commands/command.cpp @@ -294,7 +294,7 @@ int removeWeight(int index, bool currentDiveOnly) int editWeight(int index, weightsystem_t ws, bool currentDiveOnly) { - return execute_edit(new EditWeight(index, ws, currentDiveOnly)); + return execute_edit(new EditWeight(index, std::move(ws), currentDiveOnly)); } int addCylinder(bool currentDiveOnly) @@ -309,7 +309,7 @@ int removeCylinder(int index, bool currentDiveOnly) int editCylinder(int index, cylinder_t cyl, EditCylinderType type, bool currentDiveOnly) { - return execute_edit(new EditCylinder(index, cyl, type, currentDiveOnly)); + return execute_edit(new EditCylinder(index, std::move(cyl), type, currentDiveOnly)); } void editSensors(int toCylinder, int fromCylinder, int dcNr) diff --git a/core/equipment.cpp b/core/equipment.cpp index 540b31da4..229b2f4f1 100644 --- a/core/equipment.cpp +++ b/core/equipment.cpp @@ -407,7 +407,7 @@ void add_default_cylinder(struct dive *d) cyl.type.size.mliter = 11100; cyl.type.workingpressure.mbar = 207000; } - d->cylinders.add(0, cyl); + d->cylinders.add(0, std::move(cyl)); reset_cylinders(d, false); } diff --git a/core/liquivision.cpp b/core/liquivision.cpp index e7b83d1da..9146d966e 100644 --- a/core/liquivision.cpp +++ b/core/liquivision.cpp @@ -148,7 +148,7 @@ static void parse_dives(int log_version, const unsigned char *buf, unsigned int /* Just the main cylinder until we can handle the buddy cylinder porperly */ for (i = 0; i < 1; i++) { cylinder_t cyl = default_cylinder(dive.get()); - dive->cylinders.add(i, cyl); + dive->cylinders.add(i, std::move(cyl)); } // Model 0=Xen, 1,2=Xeo, 4=Lynx, other=Liquivision diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 44cff14e8..fcbec1f57 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -469,11 +469,11 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in if (inPlanner) { // In the planner - simply overwrite the cylinder in the dive with the modified cylinder. - *d->get_cylinder(row) = cyl; + *d->get_cylinder(row) = std::move(cyl); dataChanged(index, index); } else { // On the EquipmentTab - place an editCylinder command. - int count = Command::editCylinder(index.row(), cyl, type, false); + int count = Command::editCylinder(index.row(), std::move(cyl), type, false); emit divesEdited(count); } return true; diff --git a/qt-models/weightmodel.cpp b/qt-models/weightmodel.cpp index d2a7c2113..7c14be60a 100644 --- a/qt-models/weightmodel.cpp +++ b/qt-models/weightmodel.cpp @@ -88,7 +88,7 @@ void WeightModel::setTempWS(int row, weightsystem_t ws) const weightsystem_t &oldWS = d->weightsystems[row]; if (oldWS.description != ws.description) { tempRow = row; - tempWS = ws; + tempWS = std::move(ws); // If the user had already set a weight, don't overwrite that if (oldWS.weight.grams && !oldWS.auto_filled) @@ -133,7 +133,7 @@ bool WeightModel::setData(const QModelIndex &index, const QVariant &value, int r case WEIGHT: ws.weight = string_to_weight(qPrintable(vString)); ws.auto_filled = false; - int count = Command::editWeight(index.row(), ws, false); + int count = Command::editWeight(index.row(), std::move(ws), false); emit divesEdited(count); return true; }