sctplab/usrsctp

building fails at warning about parentheses:

hboetes opened this issue ยท 7 comments

With the latest code from git I get the error below on Ubuntu 22.04, whilst using these commands to start the build

    ./bootstrap
    ./configure --disable-programs --disable-inet --disable-inet6
    make
libtool: compile:  gcc -DPACKAGE_NAME=\"libusrsctp\" -DPACKAGE_TARNAME=\"libusrsctp\" -DPACKAGE_VERSION=\"0.9.5.0\" "-DPACKAGE_STRING=\"libusrsctp 0.9.5.0\"" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libusrsctp\" -DVERSION=\"0.9.5.0\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSCTP_DEBUG=1 -DHAVE_SOCKET=1 -DHAVE_INET_ADDR=1 -DHAVE_STDATOMIC_H=1 -DHAVE_SYS_QUEUE_H=1 -DHAVE_LINUX_IF_ADDR_H=1 -DHAVE_LINUX_RTNETLINK_H=1 -DHAVE_NETINET_IP_ICMP_H=1 -DHAVE_NET_ROUTE_H=1 -I. -DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__ -O2 -pipe -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member -pedantic -Wall -Werror -g -O0 -MT netinet/libusrsctp_la-sctp_output.lo -MD -MP -MF netinet/.deps/libusrsctp_la-sctp_output.Tpo -c netinet/sctp_output.c  -fPIC -DPIC -o netinet/.libs/libusrsctp_la-sctp_output.o
netinet/sctp_output.c: In function 'sctp_med_chunk_output':
netinet/sctp_output.c:9018:41: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
 9018 |                                         use_zero_crc = asoc->zero_checksum = 2;
      |                                         ^~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:719: netinet/libusrsctp_la-sctp_output.lo] Error 1
make[1]: Leaving directory '/usr/pkgmk/work/usrsctp/src/usrsctp/usrsctplib'
make: *** [Makefile:408: all-recursive] Error 1

For anybody else running into this issue, I think this should fix it. I bet the author will have an even better solution.

diff --git a/usrsctplib/netinet/sctp_output.c b/usrsctplib/netinet/sctp_output.c
index 7f79600..4d25c0e 100755
--- a/usrsctplib/netinet/sctp_output.c
+++ b/usrsctplib/netinet/sctp_output.c
@@ -9015,7 +9015,8 @@ again_one_more_time:
 					 * flight size since this little guy
 					 * is a control only packet.
 					 */
-					use_zero_crc = asoc->zero_checksum = 2;
+					asoc->zero_checksum = 2;
+					use_zero_crc = 2;
 					if (asconf) {
 						sctp_timer_start(SCTP_TIMER_TYPE_ASCONF, inp, stcb, net);
 						use_zero_crc = false;

Looks like it's failing on their own CI via GitHub actions as well (we noticed it via a CI we have that involves usrsctp). @tuexen any chance this can be fixed as @hboetes suggested? Or would you rather one of us prepare a PR with the fix?

use_zero_crc = asoc->zero_checksum = 2;
-> use_zero_crc = asoc->zero_checksum == 2;

Temp. workaround as described above by @hboetes :
sed -i -e 's|use_zero_crc = asoc->zero_checksum = 2;|asoc->zero_checksum = 2;\n\t\t\t\t\tuse_zero_crc = 2;|g' usrsctplib/netinet/sctp_output.c

@LeaTaka well, that really depends on what the original meaning of the commit was: was it a double assignment, as @hboetes assumed, or was it a "set this variable to 1 only if this other value is equal to 2" as @kschoi93 interpreted it instead? Without more context from the usrsctp developers, I'm not sure what patch makes more sense (since I'm not that familiar with the code internals).

that's right. i agree with you
It is not known which answer is correct unless the developer of usrsctp directly looks at this problem.

but I think it is a problem with the code writing rules of the C language.

I confirmed the commit to fix the problem code. @lminiero
f9f9502

Closed with f9f9502