Skip to content

Commit

Permalink
Validate option setting for calibrations. Fix a coverity issue
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Aug 14, 2024
1 parent a0d4746 commit 6c878f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions common/on-chip-calib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ namespace rs2
if( it != _sub->options_metadata.end() ) // Option supported
{
it->second.set_option( RS2_OPTION_EMITTER_ENABLED, value, ignored_error_message );
if( it->second.value_as_float() != value )
throw std::runtime_error( rsutils::string::from()
<< "Failed to set laser " << ( value == off_value ? "off" : "on" ) );
}
}

Expand All @@ -143,6 +146,9 @@ namespace rs2
if( it != _sub->options_metadata.end() ) // Option supported
{
it->second.set_option( RS2_OPTION_THERMAL_COMPENSATION, value, ignored_error_message );
if( it->second.value_as_float() != value )
throw std::runtime_error( rsutils::string::from()
<< "Failed to set laser " << ( value == off_value ? "off" : "on" ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/option-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ bool option_model::draw_slider( notifications_model & model,
{
buff_str = convert_float_str( buff_str, 0.01f );
memset( buff, 0, TEXT_BUFF_SIZE );
strcpy( buff, buff_str.c_str() );
strncpy( buff, buff_str.c_str(), TEXT_BUFF_SIZE - 1 );
}
edit_value = buff;
}
Expand Down

0 comments on commit 6c878f3

Please sign in to comment.