Include error library value in C error source files instead of fixing up
[openssl.git] / crypto / err / err.c
index 286bf4250c65e9e86d16bf0c084f6f4e5084c281..549229bcfb39f8709af911524937d1daf556553e 100644 (file)
@@ -149,7 +149,6 @@ static ERR_STRING_DATA ERR_str_libraries[]=
 {ERR_PACK(ERR_LIB_DSO,0,0)             ,"DSO support routines"},
 {ERR_PACK(ERR_LIB_ENGINE,0,0)          ,"engine routines"},
 {ERR_PACK(ERR_LIB_OCSP,0,0)            ,"OCSP routines"},
-{ERR_PACK(ERR_LIB_FIPS,0,0)            ,"FIPS routines"},
 {0,NULL},
        };
 
@@ -542,7 +541,7 @@ static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1];
  * will be returned for SYSerr(), which always gets an errno
  * value and never one of those 'standard' reason codes. */
 
-static void build_SYS_str_reasons()
+static void build_SYS_str_reasons(void)
        {
        /* OPENSSL_malloc cannot be used here, use static storage instead */
        static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
@@ -632,7 +631,8 @@ static void err_load_strings(int lib, ERR_STRING_DATA *str)
        {
        while (str->error)
                {
-               str->error|=ERR_PACK(lib,0,0);
+               if (lib)
+                       str->error|=ERR_PACK(lib,0,0);
                ERRFN(err_set_item)(str);
                str++;
                }
@@ -648,7 +648,8 @@ void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
        {
        while (str->error)
                {
-               str->error|=ERR_PACK(lib,0,0);
+               if (lib)
+                       str->error|=ERR_PACK(lib,0,0);
                ERRFN(err_del_item)(str);
                str++;
                }
@@ -944,7 +945,7 @@ static unsigned long err_hash(const void *a_void)
        {
        unsigned long ret,l;
 
-       l=((ERR_STRING_DATA *)a_void)->error;
+       l=((const ERR_STRING_DATA *)a_void)->error;
        ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
        return(ret^ret%19*13);
        }
@@ -952,21 +953,21 @@ static unsigned long err_hash(const void *a_void)
 /* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */
 static int err_cmp(const void *a_void, const void *b_void)
        {
-       return((int)(((ERR_STRING_DATA *)a_void)->error -
-                       ((ERR_STRING_DATA *)b_void)->error));
+       return((int)(((const ERR_STRING_DATA *)a_void)->error -
+                       ((const ERR_STRING_DATA *)b_void)->error));
        }
 
 /* static unsigned long pid_hash(ERR_STATE *a) */
 static unsigned long pid_hash(const void *a_void)
        {
-       return(((ERR_STATE *)a_void)->pid*13);
+       return(((const ERR_STATE *)a_void)->pid*13);
        }
 
 /* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */
 static int pid_cmp(const void *a_void, const void *b_void)
        {
-       return((int)((long)((ERR_STATE *)a_void)->pid -
-                       (long)((ERR_STATE *)b_void)->pid));
+       return((int)((long)((const ERR_STATE *)a_void)->pid -
+                       (long)((const ERR_STATE *)b_void)->pid));
        }
 
 void ERR_remove_state(unsigned long pid)
@@ -1076,7 +1077,7 @@ void ERR_add_error_data(int num, ...)
                                else
                                        str=p;
                                }
-                       BUF_strlcat(str,a,s+1);
+                       BUF_strlcat(str,a,(size_t)s+1);
                        }
                }
        ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);