Wed Mar 2 15:28:28 EET 2016

Literate programming in C: if(0)

I am not a C expert, but some code in libressl 2.3.2
(latest as of now) and openssl 1.0.1p (and probably later)
looks weird to me.
The code in libressl is in ssl/s3_clnt.c
984: if (CBS_len(&cert_list) < 3)
goto truncated;
1657: if (0) {
truncated:
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,
SSL_R_BAD_PACKET_LENGTH);
}
The weird stuff is "if (0)".
Very similar stuff is in openssl.
Asked three C coders about it.
Two of them said "this sucks much".
One said "very nice idea!", denying joking.