From 70c3cc7c037209df538bb10e0dba0ab174be21ae Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 17 Jul 2020 22:59:21 +0200 Subject: [PATCH] PVS: V646 Consider inspecting the application's logic. It's possible that 'else' keyword is missing. --- src/App/Expression.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index 37fe58ce71..bb3568e002 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -830,18 +830,21 @@ void Expression::Component::set(const Expression *owner, Py::Object &pyobj, cons void Expression::Component::del(const Expression *owner, Py::Object &pyobj) const { try { - if(!e1 && !e2 && !e3) { + if (!e1 && !e2 && !e3) { comp.del(pyobj); - } if(!comp.isRange() && !e2 && !e3) { + } + else if (!comp.isRange() && !e2 && !e3) { auto index = e1->getPyValue(); - if(pyobj.isMapping()) + if (pyobj.isMapping()) { Py::Mapping(pyobj).delItem(index); + } else { Py_ssize_t i = PyNumber_AsSsize_t(pyobj.ptr(), PyExc_IndexError); - if(PyErr_Occurred() || PySequence_DelItem(pyobj.ptr(),i)==-1) + if (PyErr_Occurred() || PySequence_DelItem(pyobj.ptr(),i)==-1) throw Py::Exception(); } - }else{ + } + else { Py::Object v1,v2,v3; if(e1) v1 = e1->getPyValue(); if(e2) v2 = e2->getPyValue(); @@ -849,13 +852,14 @@ void Expression::Component::del(const Expression *owner, Py::Object &pyobj) cons PyObject *s = PySlice_New(e1?v1.ptr():nullptr, e2?v2.ptr():nullptr, e3?v3.ptr():nullptr); - if(!s) + if (!s) throw Py::Exception(); Py::Object slice(s,true); - if(PyObject_DelItem(pyobj.ptr(),slice.ptr())<0) + if (PyObject_DelItem(pyobj.ptr(),slice.ptr())<0) throw Py::Exception(); } - }catch(Py::Exception &) { + } + catch(Py::Exception &) { EXPR_PY_THROW(owner); } }