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).
This commit is contained in:
Benjamin Nauck
2021-02-11 22:52:00 +01:00
committed by wmayer
parent e0d07257b7
commit dc444b1f09

View File

@@ -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());
}