From e113608a1c577b46512c61c7c482ee73d52d4531 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Sat, 20 Sep 2014 12:28:58 -0400 Subject: [PATCH] Switch the reason code check to a compile-time assert. It's just checking some constants. Also the comment's off now. Change-Id: I934d32b76c705758ae7c18009d867e9820a4c5a8 Reviewed-on: https://boringssl-review.googlesource.com/1800 Reviewed-by: Adam Langley --- ssl/ssl_lib.c | 7 +++++++ ssl/ssl_test.c | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 1ad825ac..ec054d26 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -172,6 +172,13 @@ SSL3_ENC_METHOD ssl3_undef_enc_method={ int use_context)) ssl_undefined_function, }; +/* Some error codes are special. Ensure the make_errors.go script + * never regresses this. */ +OPENSSL_COMPILE_ASSERT( + SSL_R_TLSV1_ALERT_NO_RENEGOTIATION == + SSL_AD_NO_RENEGOTIATION + SSL_AD_REASON_OFFSET, + ssl_alert_reason_code_mismatch); + int SSL_clear(SSL *s) { diff --git a/ssl/ssl_test.c b/ssl/ssl_test.c index 97a1967f..cc632681 100644 --- a/ssl/ssl_test.c +++ b/ssl/ssl_test.c @@ -17,14 +17,6 @@ #include "openssl/ssl.h" int main(void) { - /* Some error codes are special, but the make_errors.go script doesn't know - * this. This test will catch the case where something regenerates the error - * codes with the script but doesn't fix up the special ones. */ - if (SSL_R_TLSV1_ALERT_NO_RENEGOTIATION != 100 + SSL_AD_REASON_OFFSET) { - fprintf(stderr, "SSL alert errors don't match up.\n"); - return 1; - } - printf("PASS\n"); return 0; }