From: Ulf Möller Date: Sun, 30 Jan 2000 22:20:28 +0000 (+0000) Subject: Source code cleanups: Use void * rather than char * in lhash, X-Git-Tag: OpenSSL_0_9_5beta1~151 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9d1a01be8f84143618fc862e1222eb714949fdc1;p=oweals%2Fopenssl.git Source code cleanups: Use void * rather than char * in lhash, eliminate some of the -Wcast-qual warnings (debug-ben-strict target) --- diff --git a/Makefile.org b/Makefile.org index 0f370d2ea5..245b6b55f4 100644 --- a/Makefile.org +++ b/Makefile.org @@ -355,8 +355,8 @@ install: all chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \ done @echo installing man 1 - @for i in doc/apps/*.pod; do (cd `dirname $$i`; fn=`basename $$i .pod`; sec=`[ "$$fn" = "config" ] && echo 5 || echo 1`; ../../util/pod2man.pl --section=$$sec --date=`date +%Y-%m-%d` --center=OpenSSL --release=$(VERSION) `basename $$i` > $(INSTALL_PREFIX)$(INSTALLTOP)/man/man$$sec/`basename $$i .pod`.$$sec); done + @for i in doc/apps/*.pod; do (cd `dirname $$i`; fn=`basename $$i .pod`; sec=`[ "$$fn" = "config" ] && echo 5 || echo 1`; ../../util/pod2man.pl --section=$$sec --center=OpenSSL --release=$(VERSION) `basename $$i` > $(INSTALL_PREFIX)$(INSTALLTOP)/man/man$$sec/`basename $$i .pod`.$$sec); done @echo installing man 3 - @for i in doc/crypto/*.pod doc/ssl/*.pod; do (cd `dirname $$i`; ../../util/pod2man.pl --section=3 --date=`date +%Y-%m-%d` --center=OpenSSL --release=$(VERSION) `basename $$i` > $(INSTALL_PREFIX)$(INSTALLTOP)/man/man3/`basename $$i .pod`.3); done + @for i in doc/crypto/*.pod doc/ssl/*.pod; do (cd `dirname $$i`; ../../util/pod2man.pl --section=3 --center=OpenSSL --release=$(VERSION) `basename $$i` > $(INSTALL_PREFIX)$(INSTALLTOP)/man/man3/`basename $$i .pod`.3); done # DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/apps/openssl.c b/apps/openssl.c index 71f5ba7f67..17f9fe6ba7 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -164,7 +164,7 @@ int main(int Argc, char *Argv[]) program_name(Argv[0],pname,PROG_NAME_SIZE); f.name=pname; - fp=(FUNCTION *)lh_retrieve(prog,(char *)&f); + fp=(FUNCTION *)lh_retrieve(prog,&f); if (fp != NULL) { Argv[0]=pname; @@ -262,7 +262,7 @@ static int do_cmd(LHASH *prog, int argc, char *argv[]) if ((argc <= 0) || (argv[0] == NULL)) { ret=0; goto end; } f.name=argv[0]; - fp=(FUNCTION *)lh_retrieve(prog,(char *)&f); + fp=(FUNCTION *)lh_retrieve(prog,&f); if (fp != NULL) { ret=fp->func(argc,argv); @@ -361,7 +361,7 @@ static LHASH *prog_init(void) if ((ret=lh_new(hash,cmp)) == NULL) return(NULL); for (f=functions; f->name != NULL; f++) - lh_insert(ret,(char *)f); + lh_insert(ret,f); return(ret); } diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c index 3f2ecee5c2..92efb0ba02 100644 --- a/crypto/asn1/a_type.c +++ b/crypto/asn1/a_type.c @@ -282,7 +282,7 @@ void ASN1_TYPE_free(ASN1_TYPE *a) { if (a == NULL) return; ASN1_TYPE_component_free(a); - Free((char *)(char *)a); + Free((char *)a); } int ASN1_TYPE_get(ASN1_TYPE *a) diff --git a/crypto/asn1/p7_lib.c b/crypto/asn1/p7_lib.c index d3e596dab3..638a04c966 100644 --- a/crypto/asn1/p7_lib.c +++ b/crypto/asn1/p7_lib.c @@ -251,7 +251,7 @@ void PKCS7_free(PKCS7 *a) { ASN1_OBJECT_free(a->type); } - Free((char *)(char *)a); + Free((char *)a); } void PKCS7_content_free(PKCS7 *a) diff --git a/crypto/asn1/x_pkey.c b/crypto/asn1/x_pkey.c index 0c81558dc4..b8c30b3cd5 100644 --- a/crypto/asn1/x_pkey.c +++ b/crypto/asn1/x_pkey.c @@ -147,5 +147,5 @@ void X509_PKEY_free(X509_PKEY *x) if (x->enc_pkey != NULL) M_ASN1_OCTET_STRING_free(x->enc_pkey); if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey); if ((x->key_data != NULL) && (x->key_free)) Free((char *)x->key_data); - Free((char *)(char *)x); + Free((char *)x); } diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c index a7cd828978..f5aeb237f5 100644 --- a/crypto/bio/b_dump.c +++ b/crypto/bio/b_dump.c @@ -92,7 +92,7 @@ int BIO_dump(BIO *bio, const char *s, int len) if (((i*DUMP_WIDTH)+j)>=len) { strcat(buf," "); } else { - ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; + ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff; sprintf(tmp,"%02x%c",ch,j==7?'-':' '); strcat(buf,tmp); } @@ -101,7 +101,7 @@ int BIO_dump(BIO *bio, const char *s, int len) for(j=0;j=len) break; - ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; + ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff; #ifndef CHARSET_EBCDIC sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); #else diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c index dce0c0390b..a8610f2021 100644 --- a/crypto/bio/b_sock.c +++ b/crypto/bio/b_sock.c @@ -166,7 +166,11 @@ int BIO_get_port(const char *str, unsigned short *port_ptr) /* Note: under VMS with SOCKETSHR, it seems like the first * parameter is 'char *', instead of 'const char *' */ - s=getservbyname((char *)str,"tcp"); + s=getservbyname( +#ifndef CONST_STRICT + (char *) +#endif + str,"tcp"); if(s != NULL) *port_ptr=ntohs((unsigned short)s->s_port); CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); @@ -374,7 +378,11 @@ struct hostent *BIO_gethostbyname(const char *name) /* Note: under VMS with SOCKETSHR, it seems like the first * parameter is 'char *', instead of 'const char *' */ - ret=gethostbyname((char *)name); + ret=gethostbyname( +#ifndef CONST_STRICT + (char *) +#endif + name); if (ret == NULL) goto end; diff --git a/crypto/cast/c_ecb.c b/crypto/cast/c_ecb.c index 33182f2b71..0b3da9ad87 100644 --- a/crypto/cast/c_ecb.c +++ b/crypto/cast/c_ecb.c @@ -60,7 +60,7 @@ #include "cast_lcl.h" #include -char *CAST_version="CAST" OPENSSL_VERSION_PTEXT; +const char *CAST_version="CAST" OPENSSL_VERSION_PTEXT; void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, CAST_KEY *ks, int enc) diff --git a/crypto/conf/conf.c b/crypto/conf/conf.c index 13db218a29..3031fa3b44 100644 --- a/crypto/conf/conf.c +++ b/crypto/conf/conf.c @@ -336,7 +336,7 @@ again: ERR_R_MALLOC_FAILURE); goto err; } - vv=(CONF_VALUE *)lh_insert(ret,(char *)v); + vv=(CONF_VALUE *)lh_insert(ret,v); if (vv != NULL) { sk_CONF_VALUE_delete_ptr(ts,vv); @@ -378,7 +378,7 @@ char *CONF_get_string(LHASH *conf, char *section, char *name) { vv.name=name; vv.section=section; - v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + v=(CONF_VALUE *)lh_retrieve(conf,&vv); if (v != NULL) return(v->value); if (strcmp(section,"ENV") == 0) { @@ -388,7 +388,7 @@ char *CONF_get_string(LHASH *conf, char *section, char *name) } vv.section="default"; vv.name=name; - v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + v=(CONF_VALUE *)lh_retrieve(conf,&vv); if (v != NULL) return(v->value); else @@ -405,7 +405,7 @@ static CONF_VALUE *get_section(LHASH *conf, char *section) if ((conf == NULL) || (section == NULL)) return(NULL); vv.name=NULL; vv.section=section; - v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + v=(CONF_VALUE *)lh_retrieve(conf,&vv); return(v); } @@ -443,12 +443,12 @@ void CONF_free(LHASH *conf) conf->down_load=0; /* evil thing to make sure the 'Free()' * works as expected */ - lh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf); + lh_doall_arg(conf,(void (*)())value_free_hash,conf); /* We now have only 'section' entries in the hash table. * Due to problems with */ - lh_doall_arg(conf,(void (*)())value_free_stack,(char *)conf); + lh_doall_arg(conf,(void (*)())value_free_stack,conf); lh_free(conf); } @@ -456,7 +456,7 @@ static void value_free_hash(CONF_VALUE *a, LHASH *conf) { if (a->name != NULL) { - a=(CONF_VALUE *)lh_delete(conf,(char *)a); + a=(CONF_VALUE *)lh_delete(conf,a); } } @@ -708,7 +708,7 @@ static CONF_VALUE *new_section(LHASH *conf, char *section) v->name=NULL; v->value=(char *)sk; - vv=(CONF_VALUE *)lh_insert(conf,(char *)v); + vv=(CONF_VALUE *)lh_insert(conf,v); if (vv != NULL) { #if !defined(NO_STDIO) && !defined(WIN16) diff --git a/crypto/crypto.h b/crypto/crypto.h index 6334eab238..f58ebc4a73 100644 --- a/crypto/crypto.h +++ b/crypto/crypto.h @@ -302,12 +302,12 @@ void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), v void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); void CRYPTO_get_mem_debug_functions(void (**m)(),void (**r)(),void (**f)(),void (**so)(),long (**go)()); -void *CRYPTO_malloc_locked(int num, char *file, int line); +void *CRYPTO_malloc_locked(int num, const char *file, int line); void CRYPTO_free_locked(void *); -void *CRYPTO_malloc(int num, char *file, int line); +void *CRYPTO_malloc(int num, const char *file, int line); void CRYPTO_free(void *); -void *CRYPTO_realloc(void *addr,int num, char *file, int line); -void *CRYPTO_remalloc(void *addr,int num, char *file, int line); +void *CRYPTO_realloc(void *addr,int num, const char *file, int line); +void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); void CRYPTO_set_mem_debug_options(long bits); long CRYPTO_get_mem_debug_options(); diff --git a/crypto/des/enc_writ.c b/crypto/des/enc_writ.c index 892f15e2d7..917ec725ea 100644 --- a/crypto/des/enc_writ.c +++ b/crypto/des/enc_writ.c @@ -135,7 +135,7 @@ int des_enc_write(int fd, const void *_buf, int len, } else { - cp=(unsigned char*)buf; + cp=buf; rnum=((len+7)/8*8); /* round up to nearest eight */ } diff --git a/crypto/des/str2key.c b/crypto/des/str2key.c index 5522824952..c6abb87201 100644 --- a/crypto/des/str2key.c +++ b/crypto/des/str2key.c @@ -87,7 +87,7 @@ void des_string_to_key(const char *str, des_cblock *key) #endif des_set_odd_parity(key); des_set_key_unchecked(key,ks); - des_cbc_cksum((unsigned char*)str,key,length,ks,key); + des_cbc_cksum((const unsigned char*)str,key,length,ks,key); memset(ks,0,sizeof(ks)); des_set_odd_parity(key); } @@ -146,9 +146,9 @@ void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2) des_set_odd_parity(key1); des_set_odd_parity(key2); des_set_key_unchecked(key1,ks); - des_cbc_cksum((unsigned char*)str,key1,length,ks,key1); + des_cbc_cksum((const unsigned char*)str,key1,length,ks,key1); des_set_key_unchecked(key2,ks); - des_cbc_cksum((unsigned char*)str,key2,length,ks,key2); + des_cbc_cksum((const unsigned char*)str,key2,length,ks,key2); memset(ks,0,sizeof(ks)); des_set_odd_parity(key1); des_set_odd_parity(key2); diff --git a/crypto/err/err.c b/crypto/err/err.c index 8baa53c40d..9b4eb612ed 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -222,7 +222,7 @@ void ERR_load_strings(int lib, ERR_STRING_DATA *str) while (str->error) { str->error|=ERR_PACK(lib,0,0); - lh_insert(error_hash,(char *)str); + lh_insert(error_hash,str); str++; } CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); @@ -428,7 +428,7 @@ const char *ERR_lib_error_string(unsigned long e) if (error_hash != NULL) { d.error=ERR_PACK(l,0,0); - p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); + p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); } CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); @@ -449,7 +449,7 @@ const char *ERR_func_error_string(unsigned long e) if (error_hash != NULL) { d.error=ERR_PACK(l,f,0); - p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); + p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); } CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); @@ -470,12 +470,11 @@ const char *ERR_reason_error_string(unsigned long e) if (error_hash != NULL) { d.error=ERR_PACK(l,0,r); - p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); + p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); if (p == NULL) { d.error=ERR_PACK(0,0,r); - p=(ERR_STRING_DATA *)lh_retrieve(error_hash, - (char *)&d); + p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); } } @@ -518,7 +517,7 @@ void ERR_remove_state(unsigned long pid) pid=(unsigned long)CRYPTO_thread_id(); tmp.pid=pid; CRYPTO_w_lock(CRYPTO_LOCK_ERR); - p=(ERR_STATE *)lh_delete(thread_hash,(char *)&tmp); + p=(ERR_STATE *)lh_delete(thread_hash,&tmp); CRYPTO_w_unlock(CRYPTO_LOCK_ERR); if (p != NULL) ERR_STATE_free(p); @@ -552,7 +551,7 @@ ERR_STATE *ERR_get_state(void) else { tmp.pid=pid; - ret=(ERR_STATE *)lh_retrieve(thread_hash,(char *)&tmp); + ret=(ERR_STATE *)lh_retrieve(thread_hash,&tmp); CRYPTO_r_unlock(CRYPTO_LOCK_ERR); } @@ -570,7 +569,7 @@ ERR_STATE *ERR_get_state(void) ret->err_data_flags[i]=0; } CRYPTO_w_lock(CRYPTO_LOCK_ERR); - tmpp=(ERR_STATE *)lh_insert(thread_hash,(char *)ret); + tmpp=(ERR_STATE *)lh_insert(thread_hash,ret); CRYPTO_w_unlock(CRYPTO_LOCK_ERR); if (tmpp != NULL) /* old entry - should not happen */ { diff --git a/crypto/evp/bio_ok.c b/crypto/evp/bio_ok.c index a54384a71c..16f6e60ad8 100644 --- a/crypto/evp/bio_ok.c +++ b/crypto/evp/bio_ok.c @@ -456,7 +456,7 @@ static void sig_out(BIO* b) longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size); ctx->buf_len+= md->digest->md_size; - EVP_DigestUpdate(md, (unsigned char*)WELLKNOWN, strlen(WELLKNOWN)); + EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)); md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0])); ctx->buf_len+= md->digest->md_size; ctx->blockout= 1; @@ -480,7 +480,7 @@ static void sig_in(BIO* b) longswap(&(md->md.base[0]), md->digest->md_size); ctx->buf_off+= md->digest->md_size; - EVP_DigestUpdate(md, (unsigned char*)WELLKNOWN, strlen(WELLKNOWN)); + EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)); md->digest->final(tmp, &(md->md.base[0])); ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0; ctx->buf_off+= md->digest->md_size; diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c index 801322beb6..4d025d7ee7 100644 --- a/crypto/lhash/lhash.c +++ b/crypto/lhash/lhash.c @@ -107,12 +107,9 @@ const char *lh_version="lhash" OPENSSL_VERSION_PTEXT; #define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ #define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ - -#define P_CP char * -#define P_CPP char *,char * static void expand(LHASH *lh); static void contract(LHASH *lh); -static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash); +static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash); LHASH *lh_new(unsigned long (*h)(), int (*c)()) { @@ -179,11 +176,11 @@ void lh_free(LHASH *lh) Free((char *)lh); } -char *lh_insert(LHASH *lh, char *data) +void *lh_insert(LHASH *lh, void *data) { unsigned long hash; LHASH_NODE *nn,**rn; - char *ret; + void *ret; lh->error=0; if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)) @@ -217,11 +214,11 @@ char *lh_insert(LHASH *lh, char *data) return(ret); } -char *lh_delete(LHASH *lh, char *data) +void *lh_delete(LHASH *lh, void *data) { unsigned long hash; LHASH_NODE *nn,**rn; - char *ret; + void *ret; lh->error=0; rn=getrn(lh,data,&hash); @@ -248,11 +245,11 @@ char *lh_delete(LHASH *lh, char *data) return(ret); } -char *lh_retrieve(LHASH *lh, char *data) +void *lh_retrieve(LHASH *lh, void *data) { unsigned long hash; LHASH_NODE **rn; - char *ret; + void *ret; lh->error=0; rn=getrn(lh,data,&hash); @@ -275,7 +272,7 @@ void lh_doall(LHASH *lh, void (*func)()) lh_doall_arg(lh,func,NULL); } -void lh_doall_arg(LHASH *lh, void (*func)(), char *arg) +void lh_doall_arg(LHASH *lh, void (*func)(), void *arg) { int i; LHASH_NODE *a,*n; @@ -332,7 +329,7 @@ static void expand(LHASH *lh) if ((lh->p) >= lh->pmax) { j=(int)lh->num_alloc_nodes*2; - n=(LHASH_NODE **)Realloc((char *)lh->b, + n=(LHASH_NODE **)Realloc(lh->b, (unsigned int)sizeof(LHASH_NODE *)*j); if (n == NULL) { @@ -360,7 +357,7 @@ static void contract(LHASH *lh) lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */ if (lh->p == 0) { - n=(LHASH_NODE **)Realloc((char *)lh->b, + n=(LHASH_NODE **)Realloc(lh->b, (unsigned int)(sizeof(LHASH_NODE *)*lh->pmax)); if (n == NULL) { @@ -391,7 +388,7 @@ static void contract(LHASH *lh) } } -static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash) +static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash) { LHASH_NODE **ret,*n1; unsigned long hash,nn; @@ -426,8 +423,7 @@ static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash) } /* -static unsigned long lh_strhash(str) -char *str; +unsigned long lh_strhash(char *str) { int i,l; unsigned long ret=0; diff --git a/crypto/lhash/lhash.h b/crypto/lhash/lhash.h index 6e5a1fe708..6f6eeb2698 100644 --- a/crypto/lhash/lhash.h +++ b/crypto/lhash/lhash.h @@ -73,7 +73,7 @@ extern "C" { typedef struct lhash_node_st { - char *data; + void *data; struct lhash_node_st *next; #ifndef NO_HASH_COMP unsigned long hash; @@ -116,13 +116,13 @@ typedef struct lhash_st * in lh_insert(). */ #define lh_error(lh) ((lh)->error) -LHASH *lh_new(unsigned long (*h)(), int (*c)()); +LHASH *lh_new(unsigned long (*h)(/* void *a */), int (*c)(/* void *a,void *b */)); void lh_free(LHASH *lh); -char *lh_insert(LHASH *lh, char *data); -char *lh_delete(LHASH *lh, char *data); -char *lh_retrieve(LHASH *lh, char *data); -void lh_doall(LHASH *lh, void (*func)(/* char *b */)); -void lh_doall_arg(LHASH *lh, void (*func)(/*char *a,char *b*/),char *arg); +void *lh_insert(LHASH *lh, void *data); +void *lh_delete(LHASH *lh, void *data); +void *lh_retrieve(LHASH *lh, void *data); + void lh_doall(LHASH *lh, void (*func)(/*void *b*/)); +void lh_doall_arg(LHASH *lh, void (*func)(/*void *a,void *b*/),void *arg); unsigned long lh_strhash(const char *c); #ifndef NO_FP_API diff --git a/crypto/md5/md5_dgst.c b/crypto/md5/md5_dgst.c index ba0115ae79..9ff9f938cc 100644 --- a/crypto/md5/md5_dgst.c +++ b/crypto/md5/md5_dgst.c @@ -60,7 +60,7 @@ #include "md5_locl.h" #include -char *MD5_version="MD5" OPENSSL_VERSION_PTEXT; +const char *MD5_version="MD5" OPENSSL_VERSION_PTEXT; /* Implemented from RFC1321 The MD5 Message-Digest Algorithm */ diff --git a/crypto/mem.c b/crypto/mem.c index 67f8d12cc0..dac3d2685c 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -159,7 +159,7 @@ void CRYPTO_get_mem_debug_functions(void (**m)(), void (**r)(), void (**f)(),voi } -void *CRYPTO_malloc_locked(int num, char *file, int line) +void *CRYPTO_malloc_locked(int num, const char *file, int line) { char *ret = NULL; @@ -191,7 +191,7 @@ void CRYPTO_free_locked(void *str) free_debug_func(NULL, 1); } -void *CRYPTO_malloc(int num, char *file, int line) +void *CRYPTO_malloc(int num, const char *file, int line) { char *ret = NULL; @@ -211,7 +211,7 @@ void *CRYPTO_malloc(int num, char *file, int line) return ret; } -void *CRYPTO_realloc(void *str, int num, char *file, int line) +void *CRYPTO_realloc(void *str, int num, const char *file, int line) { char *ret = NULL; @@ -239,7 +239,7 @@ void CRYPTO_free(void *str) free_debug_func(NULL, 1); } -void *CRYPTO_remalloc(void *a, int num, char *file, int line) +void *CRYPTO_remalloc(void *a, int num, const char *file, int line) { if (a != NULL) Free(a); a=(char *)Malloc(num); diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index f3ad5ff235..ad5297bc01 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -257,7 +257,7 @@ static APP_INFO *pop_info() if (amih != NULL) { tmp.thread=CRYPTO_thread_id(); - if ((ret=(APP_INFO *)lh_delete(amih,(char *)&tmp)) != NULL) + if ((ret=(APP_INFO *)lh_delete(amih,&tmp)) != NULL) { APP_INFO *next=ret->next; diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index e8aa7dace1..3086b15161 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -132,7 +132,7 @@ const char *OBJ_NAME_get(const char *name, int type) for (;;) { - ret=(OBJ_NAME *)lh_retrieve(names_lh,(char *)&on); + ret=(OBJ_NAME *)lh_retrieve(names_lh,&on); if (ret == NULL) return(NULL); if ((ret->alias) && !alias) { @@ -168,7 +168,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data) onp->type=type; onp->data=data; - ret=(OBJ_NAME *)lh_insert(names_lh,(char *)onp); + ret=(OBJ_NAME *)lh_insert(names_lh,onp); if (ret != NULL) { /* free things */ @@ -203,7 +203,7 @@ int OBJ_NAME_remove(const char *name, int type) type&= ~OBJ_NAME_ALIAS; on.name=name; on.type=type; - ret=(OBJ_NAME *)lh_delete(names_lh,(char *)&on); + ret=(OBJ_NAME *)lh_delete(names_lh,&on); if (ret != NULL) { /* free things */ diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index aa5c50e5cc..6eeb530802 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -234,7 +234,7 @@ int OBJ_add_object(ASN1_OBJECT *obj) { ao[i]->type=i; ao[i]->obj=o; - aop=(ADDED_OBJ *)lh_insert(added,(char *)ao[i]); + aop=(ADDED_OBJ *)lh_insert(added,ao[i]); /* memory leak, buit should not normally matter */ if (aop != NULL) Free(aop); @@ -272,7 +272,7 @@ ASN1_OBJECT *OBJ_nid2obj(int n) ad.type=ADDED_NID; ad.obj= &ob; ob.nid=n; - adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); + adp=(ADDED_OBJ *)lh_retrieve(added,&ad); if (adp != NULL) return(adp->obj); else @@ -304,7 +304,7 @@ const char *OBJ_nid2sn(int n) ad.type=ADDED_NID; ad.obj= &ob; ob.nid=n; - adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); + adp=(ADDED_OBJ *)lh_retrieve(added,&ad); if (adp != NULL) return(adp->obj->sn); else @@ -336,7 +336,7 @@ const char *OBJ_nid2ln(int n) ad.type=ADDED_NID; ad.obj= &ob; ob.nid=n; - adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); + adp=(ADDED_OBJ *)lh_retrieve(added,&ad); if (adp != NULL) return(adp->obj->ln); else @@ -361,7 +361,7 @@ int OBJ_obj2nid(ASN1_OBJECT *a) { ad.type=ADDED_DATA; ad.obj=a; - adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); + adp=(ADDED_OBJ *)lh_retrieve(added,&ad); if (adp != NULL) return (adp->obj->nid); } op=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ, @@ -500,7 +500,7 @@ int OBJ_ln2nid(const char *s) { ad.type=ADDED_LNAME; ad.obj= &o; - adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); + adp=(ADDED_OBJ *)lh_retrieve(added,&ad); if (adp != NULL) return (adp->obj->nid); } op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)ln_objs,NUM_LN, @@ -519,7 +519,7 @@ int OBJ_sn2nid(const char *s) { ad.type=ADDED_SNAME; ad.obj= &o; - adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); + adp=(ADDED_OBJ *)lh_retrieve(added,&ad); if (adp != NULL) return (adp->obj->nid); } op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN, diff --git a/crypto/rand/rand.h b/crypto/rand/rand.h index 5ab94a779b..b5d2166b06 100644 --- a/crypto/rand/rand.h +++ b/crypto/rand/rand.h @@ -82,7 +82,7 @@ void RAND_seed(const void *buf,int num); void RAND_add(const void *buf,int num,int entropy); int RAND_load_file(const char *file,long max_bytes); int RAND_write_file(const char *file); -char *RAND_file_name(char *file,int num); +const char *RAND_file_name(char *file,int num); #ifdef WINDOWS void RAND_screen(void); #endif diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index cea9f54e73..7ff06adccc 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -184,7 +184,7 @@ err: return(err ? -1 : ret); } -char *RAND_file_name(char *buf, int size) +const char *RAND_file_name(char *buf, int size) { char *s; char *ret=NULL; diff --git a/crypto/ripemd/rmd_dgst.c b/crypto/ripemd/rmd_dgst.c index f3a5017199..be3eb2204a 100644 --- a/crypto/ripemd/rmd_dgst.c +++ b/crypto/ripemd/rmd_dgst.c @@ -60,7 +60,7 @@ #include "rmd_locl.h" #include -char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT; +const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT; # ifdef RMD160_ASM void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num); diff --git a/crypto/sha/sha1dgst.c b/crypto/sha/sha1dgst.c index dc008124e2..c09edb4cd7 100644 --- a/crypto/sha/sha1dgst.c +++ b/crypto/sha/sha1dgst.c @@ -63,7 +63,7 @@ #include -char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT; +const char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT; /* The implementation is in ../md32_common.h */ diff --git a/crypto/sha/sha_dgst.c b/crypto/sha/sha_dgst.c index 1aade357d1..894a96274a 100644 --- a/crypto/sha/sha_dgst.c +++ b/crypto/sha/sha_dgst.c @@ -63,7 +63,7 @@ #include -char *SHA_version="SHA" OPENSSL_VERSION_PTEXT; +const char *SHA_version="SHA" OPENSSL_VERSION_PTEXT; /* The implementation is in ../md32_common.h */ diff --git a/crypto/txt_db/txt_db.c b/crypto/txt_db/txt_db.c index 9a9fa5ce55..ad3527df53 100644 --- a/crypto/txt_db/txt_db.c +++ b/crypto/txt_db/txt_db.c @@ -205,7 +205,7 @@ char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value) db->error=DB_ERROR_NO_INDEX; return(NULL); } - ret=(char **)lh_retrieve(lh,(char *)value); + ret=(char **)lh_retrieve(lh,value); db->error=DB_ERROR_OK; return(ret); } @@ -306,7 +306,7 @@ int TXT_DB_insert(TXT_DB *db, char **row) { if ((db->qual[i] != NULL) && (db->qual[i](row) == 0)) continue; - r=(char **)lh_retrieve(db->index[i],(char *)row); + r=(char **)lh_retrieve(db->index[i],row); if (r != NULL) { db->error=DB_ERROR_INDEX_CLASH; @@ -329,7 +329,7 @@ int TXT_DB_insert(TXT_DB *db, char **row) { if ((db->qual[i] != NULL) && (db->qual[i](row) == 0)) continue; - lh_insert(db->index[i],(char *)row); + lh_insert(db->index[i],row); } } return(1); diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index 3e1565ea5b..a81b1900d1 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -326,8 +326,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, /* we have added it to the cache so now pull * it out again */ CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE); - tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs, - (char *)&stmp); + tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs,&stmp); CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE); if (tmp != NULL) diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index b3a4ebdd46..a20006d67e 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -377,7 +377,7 @@ X509_OBJECT *X509_OBJECT_retrieve_by_subject(LHASH *h, int type, abort(); } - tmp=(X509_OBJECT *)lh_retrieve(h,(char *)&stmp); + tmp=(X509_OBJECT *)lh_retrieve(h,&stmp); return(tmp); } diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index e5038fee12..c779dab376 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -622,13 +622,13 @@ int X509_STORE_add_cert(X509_STORE *ctx, X509 *x) X509_OBJECT_up_ref_count(obj); - r=(X509_OBJECT *)lh_insert(ctx->certs,(char *)obj); + r=(X509_OBJECT *)lh_insert(ctx->certs,obj); if (r != NULL) { /* oops, put it back */ - lh_delete(ctx->certs,(char *)obj); + lh_delete(ctx->certs,obj); X509_OBJECT_free_contents(obj); Free(obj); - lh_insert(ctx->certs,(char *)r); + lh_insert(ctx->certs,r); X509err(X509_F_X509_STORE_ADD_CERT,X509_R_CERT_ALREADY_IN_HASH_TABLE); ret=0; } @@ -657,13 +657,13 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x) X509_OBJECT_up_ref_count(obj); - r=(X509_OBJECT *)lh_insert(ctx->certs,(char *)obj); + r=(X509_OBJECT *)lh_insert(ctx->certs,obj); if (r != NULL) { /* oops, put it back */ - lh_delete(ctx->certs,(char *)obj); + lh_delete(ctx->certs,obj); X509_OBJECT_free_contents(obj); Free(obj); - lh_insert(ctx->certs,(char *)r); + lh_insert(ctx->certs,r); X509err(X509_F_X509_STORE_ADD_CRL,X509_R_CERT_ALREADY_IN_HASH_TABLE); ret=0; } diff --git a/ssl/s23_lib.c b/ssl/s23_lib.c index e2c3bb47da..41843dfea2 100644 --- a/ssl/s23_lib.c +++ b/ssl/s23_lib.c @@ -67,7 +67,7 @@ static int ssl23_write(SSL *s, const void *buf, int len); static long ssl23_default_timeout(void ); static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p); -char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT; +const char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT; static SSL_METHOD SSLv23_data= { TLS1_VERSION, diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index ce68732e60..b500b2315f 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -903,7 +903,7 @@ static int ssl3_send_server_key_exchange(SSL *s) unsigned int u; #endif #ifndef NO_DH - DH *dh,*dhp; + DH *dh=NULL,*dhp; #endif EVP_PKEY *pkey; unsigned char *p,*d; diff --git a/ssl/ssl.h b/ssl/ssl.h index 3ada66d9ab..79033329f0 100644 --- a/ssl/ssl.h +++ b/ssl/ssl.h @@ -1042,7 +1042,7 @@ long SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg); long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg); int SSL_get_error(SSL *s,int ret_code); -char * SSL_get_version(SSL *s); +const char *SSL_get_version(SSL *s); /* This sets the 'default' SSL version that SSL_new() will create */ int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 1c58dec45f..4eabc612ef 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -64,7 +64,7 @@ #include #include "ssl_locl.h" -char *SSL_version_str=OPENSSL_VERSION_TEXT; +const char *SSL_version_str=OPENSSL_VERSION_TEXT; static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_meth=NULL; static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_ctx_meth=NULL; @@ -1615,7 +1615,7 @@ SSL_METHOD *ssl_bad_method(int ver) return(NULL); } -char *SSL_get_version(SSL *s) +const char *SSL_get_version(SSL *s) { if (s->version == TLS1_VERSION) return("TLSv1"); diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index cab50d107f..9e01f72753 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -180,8 +180,7 @@ int ssl_get_new_session(SSL *s, int session) RAND_pseudo_bytes(ss->session_id,ss->session_id_length); CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); - r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, - (char *)ss); + r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, ss); CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); if (r == NULL) break; /* else - woops a session_id match */ @@ -225,7 +224,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len) if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) { CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); - ret=(SSL_SESSION *)lh_retrieve(s->ctx->sessions,(char *)&data); + ret=(SSL_SESSION *)lh_retrieve(s->ctx->sessions,&data); if (ret != NULL) /* don't allow other threads to steal it: */ CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); @@ -358,7 +357,7 @@ int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c) /* if session c is in already in cache, we take back the increment later */ CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); - s=(SSL_SESSION *)lh_insert(ctx->sessions,(char *)c); + s=(SSL_SESSION *)lh_insert(ctx->sessions,c); /* s != NULL iff we already had a session with the given PID. * In this case, s == c should hold (then we did not really modify @@ -424,7 +423,7 @@ static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck) if ((c != NULL) && (c->session_id_length != 0)) { if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); - r=(SSL_SESSION *)lh_delete(ctx->sessions,(char *)c); + r=(SSL_SESSION *)lh_delete(ctx->sessions,c); if (r != NULL) { ret=1; @@ -585,7 +584,7 @@ static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p) { /* The reason we don't call SSL_CTX_remove_session() is to * save on locking overhead */ - lh_delete(p->cache,(char *)s); + lh_delete(p->cache,s); SSL_SESSION_list_remove(p->ctx,s); s->not_resumable=1; if (p->ctx->remove_session_cb != NULL) @@ -606,7 +605,7 @@ void SSL_CTX_flush_sessions(SSL_CTX *s, long t) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); i=tp.cache->down_load; tp.cache->down_load=0; - lh_doall_arg(tp.cache,(void (*)())timeout,(char *)&tp); + lh_doall_arg(tp.cache,(void (*)())timeout,&tp); tp.cache->down_load=i; CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); } diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index b734528da0..531969b421 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -60,7 +60,7 @@ #include #include "ssl_locl.h" -char *tls1_version_str="TLSv1" OPENSSL_VERSION_PTEXT; +const char *tls1_version_str="TLSv1" OPENSSL_VERSION_PTEXT; static long tls1_default_timeout(void);