add va_list version of ERR_add_error_data
[openssl.git] / crypto / err / err.c
index 66d4da85560c38eb8c3f0de03b8b65b8a48874d7..fcdb244008f66d0f8ca10e2947092307b82e2003 100644 (file)
@@ -153,8 +153,9 @@ static ERR_STRING_DATA ERR_str_libraries[]=
 {ERR_PACK(ERR_LIB_TS,0,0)              ,"time stamp routines"},
 {ERR_PACK(ERR_LIB_ENGINE,0,0)          ,"engine routines"},
 {ERR_PACK(ERR_LIB_OCSP,0,0)            ,"OCSP routines"},
-{ERR_PACK(ERR_LIB_HMAC,0,0)            ,"HMAC routines"},
+{ERR_PACK(ERR_LIB_FIPS,0,0)            ,"FIPS routines"},
 {ERR_PACK(ERR_LIB_CMS,0,0)             ,"CMS routines"},
+{ERR_PACK(ERR_LIB_HMAC,0,0)            ,"HMAC routines"},
 {0,NULL},
        };
 
@@ -337,14 +338,14 @@ static unsigned long err_string_data_hash(const ERR_STRING_DATA *a)
        ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
        return(ret^ret%19*13);
        }
-static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA);
+static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA)
 
 static int err_string_data_cmp(const ERR_STRING_DATA *a,
                               const ERR_STRING_DATA *b)
        {
        return (int)(a->error - b->error);
        }
-static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA);
+static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA)
 
 static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create)
        {
@@ -428,15 +429,15 @@ static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
 
 static unsigned long err_state_hash(const ERR_STATE *a)
        {
-       return CRYPTO_THREADID_hash(&a->tid);
+       return CRYPTO_THREADID_hash(&a->tid) * 13;
        }
-static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE);
+static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE)
 
 static int err_state_cmp(const ERR_STATE *a, const ERR_STATE *b)
        {
        return CRYPTO_THREADID_cmp(&a->tid, &b->tid);
        }
-static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE);
+static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE)
 
 static LHASH_OF(ERR_STATE) *int_thread_get(int create)
        {
@@ -979,14 +980,14 @@ const char *ERR_reason_error_string(unsigned long e)
        return((p == NULL)?NULL:p->string);
        }
 
-void ERR_remove_thread_state(CRYPTO_THREADID *tid)
+void ERR_remove_thread_state(const CRYPTO_THREADID *id)
        {
        ERR_STATE tmp;
 
-       if (tid)
-               CRYPTO_THREADID_cpy(&tmp.tid, tid);
+       if (id)
+               CRYPTO_THREADID_cpy(&tmp.tid, id);
        else
-               CRYPTO_THREADID_set(&tmp.tid);
+               CRYPTO_THREADID_current(&tmp.tid);
        err_fns_check();
        /* thread_del_item automatically destroys the LHASH if the number of
         * items reaches zero. */
@@ -1003,12 +1004,12 @@ void ERR_remove_state(unsigned long pid)
 ERR_STATE *ERR_get_state(void)
        {
        static ERR_STATE fallback;
-       CRYPTO_THREADID tid;
        ERR_STATE *ret,tmp,*tmpp=NULL;
        int i;
+       CRYPTO_THREADID tid;
 
        err_fns_check();
-       CRYPTO_THREADID_set(&tid);
+       CRYPTO_THREADID_current(&tid);
        CRYPTO_THREADID_cpy(&tmp.tid, &tid);
        ret=ERRFN(thread_get_item)(&tmp);
 
@@ -1065,6 +1066,13 @@ void ERR_set_error_data(char *data, int flags)
 void ERR_add_error_data(int num, ...)
        {
        va_list args;
+       va_start(args, num);
+       ERR_add_error_vdata(num, args);
+       va_end(args);
+       }
+
+void ERR_add_error_vdata(int num, va_list args)
+       {
        int i,n,s;
        char *str,*p,*a;
 
@@ -1073,7 +1081,6 @@ void ERR_add_error_data(int num, ...)
        if (str == NULL) return;
        str[0]='\0';
 
-       va_start(args, num);
        n=0;
        for (i=0; i<num; i++)
                {
@@ -1089,7 +1096,7 @@ void ERR_add_error_data(int num, ...)
                                if (p == NULL)
                                        {
                                        OPENSSL_free(str);
-                                       goto err;
+                                       return;
                                        }
                                else
                                        str=p;
@@ -1098,9 +1105,6 @@ void ERR_add_error_data(int num, ...)
                        }
                }
        ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);
-
-err:
-       va_end(args);
        }
 
 int ERR_set_mark(void)