From c4cbdc1013c7ec947b5df23abf62ca01aef65bf8 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Mon, 9 Oct 2023 21:28:13 -0400 Subject: [PATCH] Fix CodeQL issues Signed-off-by: Geoff Hutchison --- avogadro/qtplugins/aligntool/aligntool.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/avogadro/qtplugins/aligntool/aligntool.cpp b/avogadro/qtplugins/aligntool/aligntool.cpp index e455050aa3..3f12399de9 100644 --- a/avogadro/qtplugins/aligntool/aligntool.cpp +++ b/avogadro/qtplugins/aligntool/aligntool.cpp @@ -316,12 +316,12 @@ bool AlignTool::handleCommand(const QString& command, if (command == "centerAtom") { if (options.contains("id")) { Index atomIndex = options["id"].toInt(); - if (atomIndex >= 0 && atomIndex < m_molecule->atomCount()) + if (atomIndex < m_molecule->atomCount()) shiftAtomToOrigin(atomIndex); return true; } else if (options.contains("index")) { Index atomIndex = options["index"].toInt(); - if (atomIndex >= 0 && atomIndex < m_molecule->atomCount()) + if (atomIndex < m_molecule->atomCount()) shiftAtomToOrigin(atomIndex); return true; } @@ -344,19 +344,21 @@ bool AlignTool::handleCommand(const QString& command, if (axis >= 0 && axis < 3) { if (options.contains("id")) { Index atomIndex = options["id"].toInt(); - if (atomIndex >= 0 && atomIndex < m_molecule->atomCount()) + if (atomIndex < m_molecule->atomCount()) alignAtomToAxis(atomIndex, axis); return true; } else if (options.contains("index")) { Index atomIndex = options["index"].toInt(); - if (atomIndex >= 0 && atomIndex < m_molecule->atomCount()) + if (atomIndex < m_molecule->atomCount()) alignAtomToAxis(atomIndex, axis); return true; } } - return true; + return false; // invalid options } + + return true; // nothing to handle } } // namespace Avogadro::QtPlugins