Skip to content

Commit 7cd6bfa

Browse files
committed
GstCameraPlugin: correct cast and nullptr usage
1 parent a52f356 commit 7cd6bfa

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/GstCameraPlugin.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void GstCameraPlugin::Impl::StartStreaming()
293293

294294
void *GstCameraPlugin::Impl::StartThread(void *param)
295295
{
296-
GstCameraPlugin::Impl *impl = (GstCameraPlugin::Impl *)param;
296+
GstCameraPlugin::Impl *impl = static_cast<GstCameraPlugin::Impl *>(param);
297297
impl->StartGstThread();
298298
return nullptr;
299299
}
@@ -351,7 +351,7 @@ void GstCameraPlugin::Impl::StartGstThread()
351351
if (ret != GST_STATE_CHANGE_SUCCESS)
352352
{
353353
gzmsg << "GstCameraPlugin: GStreamer element set state returned: "
354-
<< ret << std::endl;
354+
<< static_cast<int>(ret) << std::endl;
355355
}
356356

357357
// this call blocks until the main_loop is killed
@@ -501,8 +501,8 @@ void GstCameraPlugin::Impl::OnImage(const msgs::Image &msg)
501501
if (!isGstMainLoopActive) return;
502502

503503
// Alloc buffer
504-
const guint size = width * height * 1.5;
505-
GstBuffer *buffer = gst_buffer_new_allocate(NULL, size, NULL);
504+
const auto size = static_cast<guint>(width * height * 1.5);
505+
GstBuffer *buffer = gst_buffer_new_allocate(nullptr, size, nullptr);
506506

507507
if (!buffer)
508508
{
@@ -520,8 +520,8 @@ void GstCameraPlugin::Impl::OnImage(const msgs::Image &msg)
520520
}
521521

522522
// Color Conversion from RGB to YUV
523-
cv::Mat frame = cv::Mat(height, width, CV_8UC3);
524-
cv::Mat frameYUV = cv::Mat(height, width, CV_8UC3);
523+
cv::Mat frame = cv::Mat(static_cast<int>(height), static_cast<int>(width), CV_8UC3);
524+
cv::Mat frameYUV = cv::Mat(static_cast<int>(height), static_cast<int>(width), CV_8UC3);
525525
frame.data = reinterpret_cast<unsigned char *>(
526526
const_cast<char *>(msg.data().c_str()));
527527

@@ -568,7 +568,7 @@ void GstCameraPlugin::Impl::StopStreaming()
568568
{
569569
StopGstThread();
570570

571-
pthread_join(threadId, NULL);
571+
pthread_join(threadId, nullptr);
572572
isGstMainLoopActive = false;
573573
}
574574
}

0 commit comments

Comments
 (0)