Skip to content

Commit

Permalink
PR #12465 from Tamir91: Fix Coverity issues
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir authored Dec 3, 2023
2 parents 0bc7512 + 1e32ee4 commit c918402
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ds/ds-motion-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ namespace librealsense
if (p->get_stream_type() == RS2_STREAM_ACCEL || p->get_stream_type() == RS2_STREAM_GYRO)
{
auto motion = dynamic_cast<motion_stream_profile_interface*>(p.get());
assert(motion);
if (!motion)
throw std::runtime_error("Stream profile is not motion stream profile");

auto st = p->get_stream_type();
motion->set_intrinsics([this, st]() { return get_motion_intrinsics(st); });
}
Expand Down
2 changes: 1 addition & 1 deletion src/fw-logs/fw-logs-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace librealsense

fw_log_data fw_logs_parser::parse_fw_log(const fw_logs_binary_data* fw_log_msg)
{
fw_log_data log_data;
fw_log_data log_data = fw_log_data();

if (!fw_log_msg || fw_log_msg->logs_buffer.size() == 0)
return log_data;
Expand Down
5 changes: 5 additions & 0 deletions src/gl/align-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ void align_gl::align_z_to_other(rs2::video_frame& aligned,
auto p = _pc->calculate(depth);

auto frame_ref = dynamic_cast<librealsense::depth_frame*>((librealsense::frame_interface*)aligned.get());
if (!frame_ref)
throw std::runtime_error("Frame is not depth frame, cannot cast");

auto gf = dynamic_cast<gpu_addon_interface*>(frame_ref);
if (!gf)
throw std::runtime_error("Frame is not gpu_addon_interface, cannot output texture");

gf->get_gpu_section().set_size(width, height);

Expand Down
3 changes: 3 additions & 0 deletions src/gl/upload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ namespace librealsense
if (new_f) perform_gl_action([&]()
{
auto gf = dynamic_cast<gpu_addon_interface*>((frame_interface*)new_f.get());
if (!gf)
throw std::runtime_error("Frame is not gpu_addon_interface, cannot output texture");

uint32_t output_yuv;

gf->get_gpu_section().output_texture(0, &output_yuv, TEXTYPE_UINT16);
glBindTexture(GL_TEXTURE_2D, output_yuv);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RG8, width, height, 0, GL_RG, GL_UNSIGNED_BYTE, f.get_data());
Expand Down
4 changes: 4 additions & 0 deletions src/software-sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ frame_interface * software_sensor::allocate_new_video_frame( video_stream_profil
if( frame )
{
auto vid_frame = dynamic_cast< video_frame * >( frame );

if (!vid_frame)
throw std::runtime_error("Frame is not video frame");

vid_frame->assign( profile->get_width(), profile->get_height(), stride, bpp * 8 );
auto sd = dynamic_cast< software_device * >( _owner );
sd->register_extrinsic( *profile );
Expand Down

0 comments on commit c918402

Please sign in to comment.