Compiler warning in Opus 1.5.2 (1/3)
When compiling Opus 1.5.2 within the Jamulus project on either X86_64 (Debian 12) or ARM (Raspbian 12), the following compiler warning is emitted:
gcc -c -pipe -O2 -D_REENTRANT -Wall -Wextra -fPIC -DAPP_VERSION=\"3.11.0dev-0cc2cbf2\" -DCUSTOM_MODES -D_REENTRANT -DQT_NO_DEPRECATED_WARNINGS -DHAVE_LRINTF -DHAVE_STDINT_H -DWITH_JACK -DOPUS_BUILD=1 -DUSE_ALLOCA=1 -DOPUS_HAVE_RTCD=1 -DHAVE_LRINTF=1 -DHAVE_LRINT=1 -DQT_NO_DEB
UG -DQT_WIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_XML_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -I. -Isrc -Ilibs/opus/include -Ilibs/opus/celt -Ilibs/opus/silk -Ilibs/opus/silk/float -Ilibs/opus/silk/fixed -Ilibs/opus -I/usr/include/arm-linux-gnueabihf/qt
5 -I/usr/include/arm-linux-gnueabihf/qt5/QtWidgets -I/usr/include/arm-linux-gnueabihf/qt5/QtMultimedia -I/usr/include/arm-linux-gnueabihf/qt5/QtGui -I/usr/include/arm-linux-gnueabihf/qt5/QtNetwork -I/usr/include/arm-linux-gnueabihf/qt5/QtXml -I/usr/include/arm-linux-gnueabihf
/qt5/QtConcurrent -I/usr/include/arm-linux-gnueabihf/qt5/QtCore -Irelease -I. -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -o release/repacketizer.o libs/opus/src/repacketizer.c
libs/opus/src/repacketizer.c: In function ‘opus_repacketizer_out_range_impl’:
libs/opus/src/repacketizer.c:305:11: warning: unused variable ‘ret’ [-Wunused-variable]
305 | int ret = opus_packet_extensions_generate(&data[ext_begin], ext_len, all_extensions, ext_count, 0);
| ^~~
The offending code in src/repacketizer.c
is this:
if (ext_len > 0) {
int ret = opus_packet_extensions_generate(&data[ext_begin], ext_len, all_extensions, ext_count, 0);
celt_assert(ret == ext_len);
}
For a production build, where celt_assert()
expands to nothing, the variable ret
is unused.
The warning can be suppressed by adding a void reference to the variable:
if (ext_len > 0) {
int ret = opus_packet_extensions_generate(&data[ext_begin], ext_len, all_extensions, ext_count, 0);
(void)ret; /* suppress unused warning when celt_assert() is not enabled */
celt_assert(ret == ext_len);
}
I have checked this hasn't already been addressed in the most recent commits.