Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Coverity fixes 2025.0 #2890

Merged
merged 6 commits into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ algorithmFpType KNNClassificationTrainBatchKernel<algorithmFpType, training::def
algorithmFpType * subSamples, size_t subSampleCapacity, Status & status)
{
algorithmFpType samples[__KDTREE_MEDIAN_RANDOM_SAMPLE_COUNT + 1];
const size_t sampleCount = sizeof(samples) / sizeof(samples[0]);
const size_t sampleCount = __KDTREE_MEDIAN_RANDOM_SAMPLE_COUNT + 1;

if (end - start <= sampleCount)
{
Expand Down Expand Up @@ -589,7 +589,11 @@ algorithmFpType KNNClassificationTrainBatchKernel<algorithmFpType, training::def

size_t sumMid = 0;
size_t i = 0;
for (; i < sampleCount; ++i)
// this iterates through the masterHist histogram and finds the median
// in almost all circumstances the break in the if statement will trigger
// unless masterHist does not contain sufficient data to exceed
// (end - start)/2 by the last bin.
for (; i < sampleCount - 1; ++i)
{
if (sumMid + masterHist[i] > (end - start) / 2)
{
Expand Down