Remove more bits of ERR_STRING_DATA.

Also, Clang doesn't like static asserts with the same message and
ERR_free_strings should still free the error queues, although it's badly
misnamed now.

Change-Id: Ibff8eb50f93c0b56c3eeb17a300e8501a31c3ab8
Reviewed-on: https://boringssl-review.googlesource.com/3370
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
Adam Langley 2015-02-09 18:05:57 -08:00 committed by Adam Langley
parent 29b186736c
commit cf310a6197
7 changed files with 46 additions and 82 deletions

View File

@ -778,6 +778,9 @@ int ERR_pop_to_mark(void) {
void ERR_load_crypto_strings(void) {}
void ERR_free_strings(void) {}
void ERR_free_strings(void) {
err_fns_check();
ERRFN(shutdown)(err_state_free);
}
void ERR_load_BIO_strings(void) {}

View File

@ -18,39 +18,39 @@
#include <openssl/type_check.h>
OPENSSL_COMPILE_ASSERT(ERR_LIB_NONE == 1, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_SYS == 2, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_BN == 3, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_RSA == 4, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_DH == 5, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_EVP == 6, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_BUF == 7, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_OBJ == 8, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_PEM == 9, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_DSA == 10, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_X509 == 11, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_ASN1 == 12, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_CONF == 13, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_CRYPTO == 14, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_EC == 15, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_SSL == 16, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_BIO == 17, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_PKCS7 == 18, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_PKCS8 == 19, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_X509V3 == 20, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_RAND == 21, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_ENGINE == 22, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_OCSP == 23, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_UI == 24, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_COMP == 25, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_ECDSA == 26, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_ECDH == 27, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_HMAC == 28, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_DIGEST == 29, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_CIPHER == 30, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_USER == 31, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_HKDF == 32, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == 33, library_values_changed);
OPENSSL_COMPILE_ASSERT(ERR_LIB_NONE == 1, library_values_changed_1);
OPENSSL_COMPILE_ASSERT(ERR_LIB_SYS == 2, library_values_changed_2);
OPENSSL_COMPILE_ASSERT(ERR_LIB_BN == 3, library_values_changed_3);
OPENSSL_COMPILE_ASSERT(ERR_LIB_RSA == 4, library_values_changed_4);
OPENSSL_COMPILE_ASSERT(ERR_LIB_DH == 5, library_values_changed_5);
OPENSSL_COMPILE_ASSERT(ERR_LIB_EVP == 6, library_values_changed_6);
OPENSSL_COMPILE_ASSERT(ERR_LIB_BUF == 7, library_values_changed_7);
OPENSSL_COMPILE_ASSERT(ERR_LIB_OBJ == 8, library_values_changed_8);
OPENSSL_COMPILE_ASSERT(ERR_LIB_PEM == 9, library_values_changed_9);
OPENSSL_COMPILE_ASSERT(ERR_LIB_DSA == 10, library_values_changed_10);
OPENSSL_COMPILE_ASSERT(ERR_LIB_X509 == 11, library_values_changed_11);
OPENSSL_COMPILE_ASSERT(ERR_LIB_ASN1 == 12, library_values_changed_12);
OPENSSL_COMPILE_ASSERT(ERR_LIB_CONF == 13, library_values_changed_13);
OPENSSL_COMPILE_ASSERT(ERR_LIB_CRYPTO == 14, library_values_changed_14);
OPENSSL_COMPILE_ASSERT(ERR_LIB_EC == 15, library_values_changed_15);
OPENSSL_COMPILE_ASSERT(ERR_LIB_SSL == 16, library_values_changed_16);
OPENSSL_COMPILE_ASSERT(ERR_LIB_BIO == 17, library_values_changed_17);
OPENSSL_COMPILE_ASSERT(ERR_LIB_PKCS7 == 18, library_values_changed_18);
OPENSSL_COMPILE_ASSERT(ERR_LIB_PKCS8 == 19, library_values_changed_19);
OPENSSL_COMPILE_ASSERT(ERR_LIB_X509V3 == 20, library_values_changed_20);
OPENSSL_COMPILE_ASSERT(ERR_LIB_RAND == 21, library_values_changed_21);
OPENSSL_COMPILE_ASSERT(ERR_LIB_ENGINE == 22, library_values_changed_22);
OPENSSL_COMPILE_ASSERT(ERR_LIB_OCSP == 23, library_values_changed_23);
OPENSSL_COMPILE_ASSERT(ERR_LIB_UI == 24, library_values_changed_24);
OPENSSL_COMPILE_ASSERT(ERR_LIB_COMP == 25, library_values_changed_25);
OPENSSL_COMPILE_ASSERT(ERR_LIB_ECDSA == 26, library_values_changed_26);
OPENSSL_COMPILE_ASSERT(ERR_LIB_ECDH == 27, library_values_changed_27);
OPENSSL_COMPILE_ASSERT(ERR_LIB_HMAC == 28, library_values_changed_28);
OPENSSL_COMPILE_ASSERT(ERR_LIB_DIGEST == 29, library_values_changed_29);
OPENSSL_COMPILE_ASSERT(ERR_LIB_CIPHER == 30, library_values_changed_30);
OPENSSL_COMPILE_ASSERT(ERR_LIB_USER == 31, library_values_changed_31);
OPENSSL_COMPILE_ASSERT(ERR_LIB_HKDF == 32, library_values_changed_32);
OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == 33, library_values_changed_num);
static const uint32_t kFunctionValues[] = {
0xc3232b0,

View File

@ -272,9 +272,9 @@ func main() {
`)
for i, name := range libraryNames {
fmt.Fprintf(out, "OPENSSL_COMPILE_ASSERT(ERR_LIB_%s == %d, library_values_changed);\n", name, i+1)
fmt.Fprintf(out, "OPENSSL_COMPILE_ASSERT(ERR_LIB_%s == %d, library_values_changed_%d);\n", name, i+1, i+1)
}
fmt.Fprintf(out, "OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == %d, library_values_changed);\n", len(libraryNames) + 1)
fmt.Fprintf(out, "OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == %d, library_values_changed_num);\n", len(libraryNames) + 1)
out.WriteString("\n")
e.functions.WriteTo(out, "Function")

View File

@ -116,7 +116,6 @@
DEFINE_LHASH_OF(ERR_STATE);
DEFINE_LHASH_OF(ERR_STRING_DATA);
/* state_hash is a map from thread ID to ERR_STATE. It works like thread-local
* storage. */

View File

@ -1,6 +1,9 @@
#!/bin/sh
cat > lhash_macros.h << EOF
include_dir=../../include/openssl
out=${include_dir}/lhash_macros.h
cat > $out << EOF
/* Copyright (c) 2014, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
@ -24,7 +27,7 @@ EOF
output_lhash () {
type=$1
cat >> lhash_macros.h << EOF
cat >> $out << EOF
/* ${type} */
#define lh_${type}_new(hash, comp)\\
((LHASH_OF(${type})*) lh_new(CHECKED_CAST(lhash_hash_func, uint32_t (*) (const ${type} *), hash), CHECKED_CAST(lhash_cmp_func, int (*) (const ${type} *a, const ${type} *b), comp)))
@ -54,11 +57,11 @@ output_lhash () {
EOF
}
lhash_types=$(cat lhash.h | grep '^ \* LHASH_OF:' | sed -e 's/.*LHASH_OF://' -e 's/ .*//')
lhash_types=$(cat ${include_dir}/lhash.h | grep '^ \* LHASH_OF:' | sed -e 's/.*LHASH_OF://' -e 's/ .*//')
for type in $lhash_types; do
echo Hash of ${type}
output_lhash "${type}"
done
clang-format -i lhash_macros.h
clang-format -i $out

View File

@ -97,7 +97,6 @@ extern "C" {
* LHASH_OF:ASN1_OBJECT
* LHASH_OF:CONF_VALUE
* LHASH_OF:ERR_STATE
* LHASH_OF:ERR_STRING_DATA
* LHASH_OF:EX_CLASS_ITEM
* LHASH_OF:SSL_SESSION */

View File

@ -128,46 +128,6 @@
void (*)(ERR_STATE *, void *), func), \
arg);
/* ERR_STRING_DATA */
#define lh_ERR_STRING_DATA_new(hash, comp) \
((LHASH_OF(ERR_STRING_DATA) *)lh_new( \
CHECKED_CAST(lhash_hash_func, uint32_t (*)(const ERR_STRING_DATA *), \
hash), \
CHECKED_CAST( \
lhash_cmp_func, \
int (*)(const ERR_STRING_DATA *a, const ERR_STRING_DATA *b), comp)))
#define lh_ERR_STRING_DATA_free(lh) \
lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh));
#define lh_ERR_STRING_DATA_num_items(lh) \
lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh))
#define lh_ERR_STRING_DATA_retrieve(lh, data) \
((ERR_STRING_DATA *)lh_retrieve( \
CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \
CHECKED_CAST(void *, ERR_STRING_DATA *, data)))
#define lh_ERR_STRING_DATA_insert(lh, old_data, data) \
lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \
CHECKED_CAST(void **, ERR_STRING_DATA **, old_data), \
CHECKED_CAST(void *, ERR_STRING_DATA *, data))
#define lh_ERR_STRING_DATA_delete(lh, data) \
((ERR_STRING_DATA *)lh_delete( \
CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \
CHECKED_CAST(void *, ERR_STRING_DATA *, data)))
#define lh_ERR_STRING_DATA_doall(lh, func) \
lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \
CHECKED_CAST(void (*)(void *), void (*)(ERR_STRING_DATA *), func));
#define lh_ERR_STRING_DATA_doall_arg(lh, func, arg) \
lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \
CHECKED_CAST(void (*)(void *, void *), \
void (*)(ERR_STRING_DATA *, void *), func), \
arg);
/* EX_CLASS_ITEM */
#define lh_EX_CLASS_ITEM_new(hash, comp) \
((LHASH_OF(EX_CLASS_ITEM) *)lh_new( \