From dc444b1f092f551cddde479237e5f915400ea363 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Thu, 11 Feb 2021 22:52:00 +0100 Subject: [PATCH] Spreadsheet: Fix coverity warning There are no reason to check the return values for these functions as the string passed as an argument will be set to an empty string if it false. An empty string is a valid option in these instances. Coverity warnings fixed: CID 316520 (1 of 1): Unchecked return value (CHECKED_RETURN) 3. check_return: Calling getAlias without checking return value (as is done elsewhere 8 out of 10 times). CID 316557 (1 of 1): Unchecked return value (CHECKED_RETURN) 8. check_return: Calling getAlias without checking return value (as is done elsewhere 8 out of 10 times). --- src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp index 6032380cad..cac8a3a8f6 100644 --- a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp +++ b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp @@ -234,10 +234,8 @@ void SheetView::updateContentLine() if (i.isValid()) { std::string str; - Cell * cell = sheet->getCell(CellAddress(i.row(), i.column())); - - if (cell) - cell->getStringContent(str); + if (const auto * cell = sheet->getCell(CellAddress(i.row(), i.column()))) + (void)cell->getStringContent(str); ui->cellContent->setText(QString::fromUtf8(str.c_str())); ui->cellContent->setIndex(i); ui->cellContent->setEnabled(true); @@ -253,10 +251,8 @@ void SheetView::updateAliasLine() if (i.isValid()) { std::string str; - Cell * cell = sheet->getCell(CellAddress(i.row(), i.column())); - - if (cell) - cell->getAlias(str); + if (const auto * cell = sheet->getCell(CellAddress(i.row(), i.column()))) + (void)cell->getAlias(str); ui->cellAlias->setText(QString::fromUtf8(str.c_str())); ui->cellAlias->setIndex(i); ui->cellAlias->setEnabled(true); @@ -350,12 +346,11 @@ void SheetView::editingFinished() ui->cellAlias->setDocumentObject(sheet); ui->cells->model()->setData(i, QVariant(ui->cellContent->text()), Qt::EditRole); - Cell * cell = sheet->getCell(CellAddress(i.row(), i.column())); - if (cell){ + if (const auto * cell = sheet->getCell(CellAddress(i.row(), i.column()))){ if (!aliasOkay){ //do not show error message if failure to set new alias is because it is already the same string std::string current_alias; - cell->getAlias(current_alias); + (void)cell->getAlias(current_alias); if (str != QString::fromUtf8(current_alias.c_str())){ Base::Console().Error("Unable to set alias: %s\n", Base::Tools::toStdString(str).c_str()); }