From bd6cd0e742d2b7ea6deec1d5fed150aed913e23e Mon Sep 17 00:00:00 2001 From: Shaun Roe <shaun.roe@cern.ch> Date: Mon, 15 Jul 2024 11:31:22 +0200 Subject: [PATCH] tidy headers, solve coverity 17031;possible use of uninitialised variable --- .../AthExOnnxRuntime/src/EvaluateModelWithAthInfer.cxx | 6 +++++- .../AthExOnnxRuntime/src/EvaluateModelWithAthInfer.h | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModelWithAthInfer.cxx b/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModelWithAthInfer.cxx index 69bb75607a58..fdbede393de2 100644 --- a/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModelWithAthInfer.cxx +++ b/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModelWithAthInfer.cxx @@ -55,7 +55,7 @@ StatusCode EvaluateModelWithAthInfer::execute( [[maybe_unused]] const EventConte ATH_MSG_DEBUG("Label for the input test data: "); for(int ibatch = 0; ibatch < m_batchSize; ibatch++){ float max = -999; - int max_index; + int max_index{-1}; for (int i = 0; i < 10; i++){ ATH_MSG_DEBUG("Score for class "<< i <<" = "<<outputScores[i] << " in batch " << ibatch); int index = i + ibatch * 10; @@ -64,6 +64,10 @@ StatusCode EvaluateModelWithAthInfer::execute( [[maybe_unused]] const EventConte max_index = index; } } + if (max_index<0){ + ATH_MSG_ERROR("No maximum found in EvaluateModelWithAthInfer::execute"); + return StatusCode::FAILURE; + } ATH_MSG_DEBUG("Class: "<<max_index<<" has the highest score: "<<outputScores[max_index] << " in batch " << ibatch); } diff --git a/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModelWithAthInfer.h b/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModelWithAthInfer.h index 769a4324ee99..97577f5e2b95 100644 --- a/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModelWithAthInfer.h +++ b/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModelWithAthInfer.h @@ -14,7 +14,6 @@ #include <onnxruntime_cxx_api.h> // System include(s). -#include <memory> #include <string> #include <vector> -- GitLab