qv4l2: fix valgrind warnings
authorHans Verkuil <hans.verkuil@cisco.com>
Mon, 4 Aug 2014 07:21:08 +0000 (09:21 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Mon, 4 Aug 2014 07:21:08 +0000 (09:21 +0200)
Mostly uninitialized fields, but there was also one inverted get_interval result
check.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/qv4l2/capture-win-gl.cpp
utils/qv4l2/ctrl-tab.cpp
utils/qv4l2/general-tab.cpp
utils/qv4l2/qv4l2.cpp
utils/v4l2-compliance/cv4l-helpers.h

index 29cd1e2..6132e3b 100644 (file)
@@ -126,6 +126,7 @@ CaptureWinGLEngine::CaptureWinGLEngine() :
        m_WCrop(0),
        m_HCrop(0),
        m_colorspace(V4L2_COLORSPACE_REC709),
+       m_field(V4L2_FIELD_NONE),
        m_displayColorspace(V4L2_COLORSPACE_SRGB),
        m_screenTextureCount(0),
        m_formatChange(false),
index bd023aa..db528b0 100644 (file)
@@ -642,6 +642,8 @@ void ApplicationWindow::refresh(unsigned ctrl_class)
        for (unsigned i = 0; i < count; i++) {
                unsigned id = c[cnt].id = m_classMap[ctrl_class][i];
                
+               c[cnt].size = 0;
+               c[cnt].reserved2[0] = 0;
                if (m_ctrlMap[id].type == V4L2_CTRL_TYPE_BUTTON)
                        continue;
                if (m_ctrlMap[id].flags & V4L2_CTRL_FLAG_WRITE_ONLY)
index 68079ae..02abd3f 100644 (file)
@@ -1571,7 +1571,7 @@ void GeneralTab::vbiMethodsChanged(int idx)
 
 void GeneralTab::cropChanged()
 {
-       v4l2_selection sel;
+       v4l2_selection sel = { 0 };
 
        if (!m_cropWidth->isEnabled() || !cur_io_has_crop())
                return;
@@ -1588,7 +1588,7 @@ void GeneralTab::cropChanged()
 
 void GeneralTab::composeChanged()
 {
-       v4l2_selection sel;
+       v4l2_selection sel = { 0 };
 
        if (!m_composeWidth->isEnabled() || !cur_io_has_compose())
                return;
@@ -1748,13 +1748,14 @@ void GeneralTab::updateStandard()
        v4l2_standard vs;
        QString what;
 
-       g_std(std);
-       if (!enum_std(vs, true)) {
-               do {
-                       if (vs.id == std)
-                               break;
-               } while (!enum_std(vs));
-       }
+       if (g_std(std))
+               return;
+       if (enum_std(vs, true))
+               return;
+       do {
+               if (vs.id == std)
+                       break;
+       } while (!enum_std(vs));
        if (vs.id != std) {
                if (!enum_std(vs, true)) {
                        do {
@@ -1825,13 +1826,14 @@ void GeneralTab::updateTimings()
        v4l2_enum_dv_timings p;
        QString what;
 
-       g_dv_timings(timings);
-       if (!enum_dv_timings(p, true)) {
-               do {
-                       if (!memcmp(&timings, &p.timings, sizeof(timings)))
-                               break;
-               } while (!enum_dv_timings(p));
-       }
+       if (g_dv_timings(timings))
+               return;
+       if (enum_dv_timings(p, true))
+               return;
+       do {
+               if (!memcmp(&timings, &p.timings, sizeof(timings)))
+                       break;
+       } while (!enum_dv_timings(p));
        if (memcmp(&timings, &p.timings, sizeof(timings)))
                return;
        m_videoTimings->setCurrentIndex(p.index);
@@ -1992,7 +1994,7 @@ void GeneralTab::updateCrop()
        if (m_cropWidth == NULL || !m_cropWidth->isEnabled())
                return;
 
-       v4l2_selection sel;
+       v4l2_selection sel = { 0 };
        v4l2_rect &r = sel.r;
        v4l2_rect b = { 0, 0, m_width, m_height };
 
@@ -2036,7 +2038,7 @@ void GeneralTab::updateCompose()
        if (m_composeWidth == NULL || !m_composeWidth->isEnabled())
                return;
 
-       v4l2_selection sel;
+       v4l2_selection sel = { 0 };
        v4l2_rect &r = sel.r;
        v4l2_rect b = { 0, 0, m_width, m_height };
 
index ec4edc9..2023dba 100644 (file)
@@ -1279,9 +1279,12 @@ void ApplicationWindow::capStart(bool start)
        }
 
        m_capSrcFormat.s_type(g_type());
-       g_fmt(m_capSrcFormat);
+       if (g_fmt(m_capSrcFormat)) {
+               error("could not obtain a source format\n");
+               return;
+       }
        s_fmt(m_capSrcFormat);
-       if (!m_genTab->get_interval(interval))
+       if (m_genTab->get_interval(interval))
                set_interval(interval);
 
        m_frameData = new unsigned char[m_capSrcFormat.g_sizeimage(0) +
@@ -1382,7 +1385,7 @@ void ApplicationWindow::closeDevice()
                        delete m_ctrlNotifier;
                        m_ctrlNotifier = NULL;
                }
-               delete m_frameData;
+               delete [] m_frameData;
                m_frameData = NULL;
                v4lconvert_destroy(m_convertData);
                cv4l_fd::close();
@@ -1393,6 +1396,7 @@ void ApplicationWindow::closeDevice()
                m_tabs->removeTab(0);
                delete page;
        }
+       m_genTab = NULL;
        m_ctrlMap.clear();
        m_widgetMap.clear();
        m_sliderMap.clear();
index 1b01a6c..be87055 100644 (file)
@@ -451,6 +451,7 @@ public:
                v4l2_streamparm parm;
 
                parm.type = type ? type : g_type();
+               memset(parm.parm.capture.reserved, 0, sizeof(parm.parm.capture.reserved));
                if (cv4l_ioctl(VIDIOC_G_PARM, &parm) ||
                    !(parm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME))
                        return -1;
@@ -465,6 +466,7 @@ public:
                v4l2_streamparm parm;
 
                parm.type = type ? type : g_type();
+               memset(parm.parm.capture.reserved, 0, sizeof(parm.parm.capture.reserved));
                if (cv4l_ioctl(VIDIOC_G_PARM, &parm) == 0 &&
                    (parm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME)) {
                        interval = parm.parm.capture.timeperframe;