Fwd: New Defects reported by Coverity Scan for GNURadio

FYI.

-------- Forwarded Message --------
Subject: New Defects reported by Coverity Scan for GNURadio
Date: Sun, 25 Jan 2015 23:13:10 -0800
From: [email protected]
To: [email protected]

Hi,

Please find the latest report on new defect(s) introduced to GNURadio
found with Coverity Scan.

7 new defect(s) introduced to GNURadio found with Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 7 of 7 defect(s)

** CID 1267227: Self assignment (NO_EFFECT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gr-dtv/lib/atsc/atsc_interleaver_impl.cc:
61 in gr::dtv::atsc_interleaver_impl::atsc_interleaver_impl()()

** CID 1267226: Dereference before null check (REVERSE_INULL)
/gr-digital/swig/digital_swigPYTHON_wrap.cxx: 235836 in
_wrap_new_constellation_16qam_sptr(_object *, _object *)()

** CID 1267225: Dereference before null check (REVERSE_INULL)
/gr-digital/swig/digital_swigPYTHON_wrap.cxx: 234542 in
_wrap_new_constellation_8psk_natural_sptr(_object *, _object *)()

** CID 1267224: Uncaught exception (UNCAUGHT_EXCEPT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gnuradio-runtime/apps/gnuradio-config-info.cc:
36 in main()

** CID 1267223: Uncaught exception (UNCAUGHT_EXCEPT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gnuradio-runtime/apps/gnuradio-config-info.cc:
36 in main()

** CID 1267222: Uncaught exception (UNCAUGHT_EXCEPT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gnuradio-runtime/apps/gnuradio-config-info.cc:
36 in main()

** CID 1267221: Uninitialized scalar variable (UNINIT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gr-dtv/lib/atsc/atsc_field_sync_mux_impl.cc:
199 in gr::dtv::atsc_field_sync_mux_impl::general_work(int,
std::vector<int, std::allocator> &, std::vector<const void *,
std::allocator<const void *>>&, std::vector<void *, std::allocator<void
*>>&)()


*** CID 1267227: Self assignment (NO_EFFECT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gr-dtv/lib/atsc/atsc_interleaver_impl.cc:
61 in gr::dtv::atsc_interleaver_impl::atsc_interleaver_impl()()
55 }
56
57 memset(registers, 0, sizeof(unsigned char) * I * ((I - 1) *
J));
58 memset(pointers, 0, sizeof(int) * I);
59
60 this->I = I;

CID 1267227:  Self assignment  (NO_EFFECT)
Assignment operation "this->J = this->J" has no effect.

61 this->J = J;
62 commutator = 0;
63 }
64
65 atsc_interleaver_impl::~atsc_interleaver_impl()
66 {


*** CID 1267226: Dereference before null check (REVERSE_INULL)
/gr-digital/swig/digital_swigPYTHON_wrap.cxx: 235836 in
_wrap_new_constellation_16qam_sptr(_object *, _object *)()
235830 SWIGINTERN PyObject
*_wrap_new_constellation_16qam_sptr(PyObject *self, PyObject *args) {
235831 int argc;
235832 PyObject *argv[2];
235833 int ii;
235834
235835 if (!PyTuple_Check(args)) SWIG_fail;

CID 1267226:  Dereference before null check  (REVERSE_INULL)
Null-checking "args" suggests that it may be null, but it has already been 

dereferenced on all paths leading to the check.
235836 argc = args ? (int)PyObject_Length(args) : 0;
235837 for (ii = 0; (ii < 1) && (ii < argc); ii++) {
235838 argv[ii] = PyTuple_GET_ITEM(args,ii);
235839 }
235840 if (argc == 0) {
235841 return _wrap_new_constellation_16qam_sptr__SWIG_0(self,
args);


*** CID 1267225: Dereference before null check (REVERSE_INULL)
/gr-digital/swig/digital_swigPYTHON_wrap.cxx: 234542 in
_wrap_new_constellation_8psk_natural_sptr(_object *, _object *)()
234536 SWIGINTERN PyObject
*_wrap_new_constellation_8psk_natural_sptr(PyObject *self, PyObject
*args) {
234537 int argc;
234538 PyObject *argv[2];
234539 int ii;
234540
234541 if (!PyTuple_Check(args)) SWIG_fail;

CID 1267225:  Dereference before null check  (REVERSE_INULL)
Null-checking "args" suggests that it may be null, but it has already been 

dereferenced on all paths leading to the check.
234542 argc = args ? (int)PyObject_Length(args) : 0;
234543 for (ii = 0; (ii < 1) && (ii < argc); ii++) {
234544 argv[ii] = PyTuple_GET_ITEM(args,ii);
234545 }
234546 if (argc == 0) {
234547 return
_wrap_new_constellation_8psk_natural_sptr__SWIG_0(self, args);


*** CID 1267224: Uncaught exception (UNCAUGHT_EXCEPT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gnuradio-runtime/apps/gnuradio-config-info.cc:
36 in main()
30 #include
31
32 namespace po = boost::program_options;
33 using boost::format;
34
35 int

CID 1267224:  Uncaught exception  (UNCAUGHT_EXCEPT)
In function "main" an exception of type 

"boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorboost::io::bad_format_string

" is thrown and never caught.
36 main(int argc, char **argv)
37 {
38 po::options_description desc((format(“Program options: %1%
[options]”) % argv[0]).str());
39 po::variables_map vm;
40
41 desc.add_options()


*** CID 1267223: Uncaught exception (UNCAUGHT_EXCEPT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gnuradio-runtime/apps/gnuradio-config-info.cc:
36 in main()
30 #include
31
32 namespace po = boost::program_options;
33 using boost::format;
34
35 int

CID 1267223:  Uncaught exception  (UNCAUGHT_EXCEPT)
In function "main" an exception of type 

"boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorboost::io::too_few_args

" is thrown and never caught.
36 main(int argc, char **argv)
37 {
38 po::options_description desc((format(“Program options: %1%
[options]”) % argv[0]).str());
39 po::variables_map vm;
40
41 desc.add_options()


*** CID 1267222: Uncaught exception (UNCAUGHT_EXCEPT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gnuradio-runtime/apps/gnuradio-config-info.cc:
36 in main()
30 #include
31
32 namespace po = boost::program_options;
33 using boost::format;
34
35 int

CID 1267222:  Uncaught exception  (UNCAUGHT_EXCEPT)
In function "main" an exception of type 

"boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorboost::io::too_many_args

" is thrown and never caught.
36 main(int argc, char **argv)
37 {
38 po::options_description desc((format(“Program options: %1%
[options]”) % argv[0]).str());
39 po::variables_map vm;
40
41 desc.add_options()


*** CID 1267221: Uninitialized scalar variable (UNINIT)
/var/lib/jenkins/jobs/GNURadio-master/workspace/gnuradio/gr-dtv/lib/atsc/atsc_field_sync_mux_impl.cc:
199 in gr::dtv::atsc_field_sync_mux_impl::general_work(int,
std::vector<int, std::allocator> &, std::vector<const void *,
std::allocator<const void *>>&, std::vector<void *, std::allocator<void
*>>&)()
193 }
194 else {
195 init_field_sync_2(&field_sync, d_saved_symbols);
196 }
197
198 // note that index doesn’t advance in this branch

CID 1267221:  Uninitialized scalar variable  (UNINIT)
Using uninitialized value "field_sync". Field "field_sync._pad_" is 

uninitialized.
199 out[outdex] = field_sync;
200 d_already_output_field_sync = true;
201 }
202 else {
203 // already output field sync, now output first
regular segment
204 out[outdex] = in[index];


To view the defects in Coverity Scan visit,
https://scan.coverity.com/projects/588?tab=overview

To manage Coverity Scan email notifications for “[email protected]”,
click
https://scan.coverity.com/subscriptions/edit?email=philip%40balister.org&token=e8f98366c9e8587eaa57ec261c04b7ad
.

I can address the two issues in gr-dtv.

CID 1267227 seems spurious. Coverity doesn’t complain about the previous
line,
even though it’s doing exactly the same operation. Also, the code
executes
properly, so there’s no doubt that this->J is being set.

Of course, the this-> business is a bit of a C++ trick, and can be
easily coded
in a more conventional way.

CID 1267221 is complaining about the pad field not being initialized.
The
pad field is just padding to a power of 2 and is not used. So again,
not a
bug, but can be easily changed to eliminate the complaint.

Ron

After looking at the code a little more, Coverity is correct about
CID 1267227. Not sure why it doesn’t complain about the previous
line. The original code had I and J passed in as parameters, and
setting the private variables was necessary. In the ATSC version,
I and J are fixed, so I removed the parameters but neglected
to remove the superfluous setting of the private variables.

Ron

Ron et everyone else,

Coverity lets you ‘own’ bugs so it’s clear who’s working on what. Also,
we can flag issues als false positives.

Cheers,
M