From f671066855c2de8aa3a13a3d5ed5512326314eed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 21 Jul 2014 10:14:17 +0200 Subject: [PATCH] openni2src: Fix unitialized variable compiler warning gstopenni2src.cpp:721:14: error: variable 'oni_ts' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] } else if (src->color->isValid () && src->sourcetype == SOURCETYPE_COLOR) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gstopenni2src.cpp:752:26: note: uninitialized use occurs here GST_BUFFER_PTS (buf) = oni_ts - src->oni_start_ts; ^~~~~~ gstopenni2src.cpp:721:10: note: remove the 'if' if its condition is always true } else if (src->color->isValid () && src->sourcetype == SOURCETYPE_COLOR) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gstopenni2src.cpp:721:14: error: variable 'oni_ts' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized] } else if (src->color->isValid () && src->sourcetype == SOURCETYPE_COLOR) { ^~~~~~~~~~~~~~~~~~~~~~ gstopenni2src.cpp:752:26: note: uninitialized use occurs here GST_BUFFER_PTS (buf) = oni_ts - src->oni_start_ts; ^~~~~~ gstopenni2src.cpp:721:14: note: remove the '&&' if its condition is always true } else if (src->color->isValid () && src->sourcetype == SOURCETYPE_COLOR) { ^~~~~~~~~~~~~~~~~~~~~~~~~ gstopenni2src.cpp:642:18: note: initialize the variable 'oni_ts' to silence this warning uint64_t oni_ts; ^ = 0 --- ext/openni2/gstopenni2src.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/openni2/gstopenni2src.cpp b/ext/openni2/gstopenni2src.cpp index 9a49396..a60dca4 100644 --- a/ext/openni2/gstopenni2src.cpp +++ b/ext/openni2/gstopenni2src.cpp @@ -744,6 +744,9 @@ openni2_read_gstbuffer (GstOpenni2Src * src, GstBuffer * buf) src->colorFrame->getWidth (), src->colorFrame->getHeight (), src->colorFrame->getDataSize ()); + } else { + g_return_val_if_reached (GST_FLOW_ERROR); + return GST_FLOW_ERROR; } if (G_UNLIKELY (src->oni_start_ts == GST_CLOCK_TIME_NONE)) -- 2.7.4