bastibl / gr-rds

FM RDS/TMC Transceiver
http://en.wikipedia.org/wiki/Radio_Data_System
GNU General Public License v3.0
218 stars 71 forks source link

Fix parsing of optional content #31

Closed argilo closed 4 years ago

argilo commented 4 years ago

The following warnings drew my attention to a couple bugs in decode_optional_content:

/home/argilo/prefix_next/src/gr-rds/lib/parser_impl.cc: In member function ‘void gr::rds::parser_impl::decode_optional_content(int, long unsigned int*)’:
/home/argilo/prefix_next/src/gr-rds/lib/parser_impl.cc:442:36: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
    label = (free_format[i] && (0xf << ff_pointer));
                               ~~~~~^~~~~~~~~~~~~~
/home/argilo/prefix_next/src/gr-rds/lib/parser_impl.cc:445:66: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
    content = (free_format[i] && (int(pow(2, content_length) - 1) << ff_pointer));
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

This function is meant to extract packed bit fields from free_format but uses boolean AND instead of integer AND, and fails to right-shift the extracted bits.

I also included a second commit which silences some other compiler warnings.

bastibl commented 4 years ago

thank you!