From 30b02e012eca18df2bd81e17b6f68df2335cbd41 Mon Sep 17 00:00:00 2001 From: Dhruv Khattar Date: Wed, 15 Jun 2016 17:43:00 +0530 Subject: [PATCH] Coverity #1321037-9, #1350602-5 fixed Change-Id: I686c3cc884cd1dfb0a3d4446ed2bf4f779f4fec9 --- scilab/modules/ast/src/cpp/ast/run_CallExp.hpp | 4 +- scilab/modules/ast/src/cpp/ast/runvisitor.cpp | 77 ++++++++++-------------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/scilab/modules/ast/src/cpp/ast/run_CallExp.hpp b/scilab/modules/ast/src/cpp/ast/run_CallExp.hpp index 4e52e06..ede6020 100644 --- a/scilab/modules/ast/src/cpp/ast/run_CallExp.hpp +++ b/scilab/modules/ast/src/cpp/ast/run_CallExp.hpp @@ -279,7 +279,7 @@ void RunVisitorT::visitprivate(const CallExp &e) if (pIT->isInvokable() == false) { // call overload - ret = Overload::call(L"%" + pIT->getShortTypeStr() + L"_e", in, iRetCount, out, this); + ret = Overload::call(L"%" + pIT->getShortTypeStr() + L"_e", in, iRetCount, out, true); } else { @@ -287,7 +287,7 @@ void RunVisitorT::visitprivate(const CallExp &e) if (ret == false && pIT->isUserType()) { // call overload - ret = Overload::call(L"%" + pIT->getShortTypeStr() + L"_e", in, iRetCount, out, this); + ret = Overload::call(L"%" + pIT->getShortTypeStr() + L"_e", in, iRetCount, out, true); } } diff --git a/scilab/modules/ast/src/cpp/ast/runvisitor.cpp b/scilab/modules/ast/src/cpp/ast/runvisitor.cpp index e8e71af..2dd363f 100644 --- a/scilab/modules/ast/src/cpp/ast/runvisitor.cpp +++ b/scilab/modules/ast/src/cpp/ast/runvisitor.cpp @@ -425,7 +425,7 @@ void RunVisitorT::visitprivate(const FieldExp &e) try { - Ret = Overload::call(L"%" + stType + L"_e", in, 1, out, this); + Ret = Overload::call(L"%" + stType + L"_e", in, 1, out, true); } catch (const InternalError& ie) { @@ -435,7 +435,7 @@ void RunVisitorT::visitprivate(const FieldExp &e) //tlist/mlist name are truncated to 8 first character if (stType.size() > 8) { - Ret = Overload::call(L"%" + stType.substr(0, 8) + L"_e", in, 1, out, this); + Ret = Overload::call(L"%" + stType.substr(0, 8) + L"_e", in, 1, out, true); } else { @@ -448,7 +448,7 @@ void RunVisitorT::visitprivate(const FieldExp &e) // TList or Mlist if (pValue->isList()) { - Ret = Overload::call(L"%l_e", in, 1, out, this); + Ret = Overload::call(L"%l_e", in, 1, out, true); } else { @@ -1303,7 +1303,7 @@ void RunVisitorT::visitprivate(const NotExp &e) pValue->IncreaseRef(); in.push_back(pValue); - types::Callable::ReturnValue Ret = Overload::call(L"%" + pValue->getShortTypeStr() + L"_5", in, 1, out, this); + types::Callable::ReturnValue Ret = Overload::call(L"%" + pValue->getShortTypeStr() + L"_5", in, 1, out, true); if (Ret != types::Callable::OK) { @@ -1369,11 +1369,11 @@ void RunVisitorT::visitprivate(const TransposeExp &e) types::Callable::ReturnValue Ret; if (bConjug) { - Ret = Overload::call(L"%" + getResult()->getShortTypeStr() + L"_t", in, 1, out, this); + Ret = Overload::call(L"%" + getResult()->getShortTypeStr() + L"_t", in, 1, out, true); } else { - Ret = Overload::call(L"%" + getResult()->getShortTypeStr() + L"_0", in, 1, out, this); + Ret = Overload::call(L"%" + getResult()->getShortTypeStr() + L"_0", in, 1, out, true); } if (Ret != types::Callable::OK) @@ -1860,52 +1860,39 @@ void RunVisitorT::visitprivate(const DAXPYExp &e) return; } - if (ad && xd && yd) - { - if (ac == 1 && - ar == 1 && - xr == yr && - xc == yc) - { - //go ! - int one = 1; - int size = xc * xr; - //Double* od = (Double*)yd->clone(); - C2F(daxpy)(&size, ad->get(), xd->get(), &one, yd->get(), &one); - //setResult(od); - //yd->killMe(); - xd->killMe(); - ad->killMe(); - CoverageInstance::stopChrono((void*)&e); - return; - } - else if (ac == xr && ar == yr && xc == yc) - { - char n = 'n'; - double one = 1; - C2F(dgemm)(&n, &n, &ar, &xc, &ac, &one, ad->get(), &ar, xd->get(), &ac, &one, yd->get(), &ar); - xd->killMe(); - ad->killMe(); - CoverageInstance::stopChrono((void*)&e); - return; - } - } - - if (yd) - { - yd->killMe(); - } - - if (xd) + // If we get here we are certain that ad, xd & yd have been set + if (ac == 1 && + ar == 1 && + xr == yr && + xc == yc) { + //go ! + int one = 1; + int size = xc * xr; + //Double* od = (Double*)yd->clone(); + C2F(daxpy)(&size, ad->get(), xd->get(), &one, yd->get(), &one); + //setResult(od); + //yd->killMe(); xd->killMe(); + ad->killMe(); + CoverageInstance::stopChrono((void*)&e); + return; } - - if (ad) + else if (ac == xr && ar == yr && xc == yc) { + char n = 'n'; + double one = 1; + C2F(dgemm)(&n, &n, &ar, &xc, &ac, &one, ad->get(), &ar, xd->get(), &ac, &one, yd->get(), &ar); + xd->killMe(); ad->killMe(); + CoverageInstance::stopChrono((void*)&e); + return; } + yd->killMe(); + xd->killMe(); + ad->killMe(); + try { e.getOriginal()->accept(*this); -- 1.7.9.5