From: Hallvard Furuseth Date: Tue, 17 Aug 1999 21:09:26 +0000 (+0000) Subject: Add const, to fix "cast away from const" warnings X-Git-Tag: TWEB_OL_BASE~186 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fa4c4448c467441fa0769db34ba9f566a3b40303;p=openldap Add const, to fix "cast away from const" warnings --- diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index 5780012bc7..ad1bcd7710 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -92,13 +92,14 @@ static const struct ldaperror ldap_errlist[] = { {-1, 0 } }; -static struct ldaperror *ldap_int_error( int err ) +static const struct ldaperror * +ldap_int_error( int err ) { int i; for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) { if ( err == ldap_errlist[i].e_code ) - return (struct ldaperror *) &ldap_errlist[i]; + return &ldap_errlist[i]; } return NULL; @@ -107,7 +108,7 @@ static struct ldaperror *ldap_int_error( int err ) char * ldap_err2string( int err ) { - struct ldaperror *e; + const struct ldaperror *e; Debug( LDAP_DEBUG_TRACE, "ldap_err2string\n", 0, 0, 0 ); @@ -121,7 +122,7 @@ void ldap_perror( LDAP *ld, LDAP_CONST char *str ) { const char *s; - struct ldaperror *e; + const struct ldaperror *e; Debug( LDAP_DEBUG_TRACE, "ldap_perror\n", 0, 0, 0 ); assert( ld != NULL ); diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index c66ac0ab1f..0d978e3274 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -381,7 +381,7 @@ ldap_set_option( case LDAP_OPT_TIMEOUT: { const struct timeval *tv = - (struct timeval *) invalue; + (const struct timeval *) invalue; if ( lo->ldo_tm_api != NULL ) { LDAP_FREE( lo->ldo_tm_api ); @@ -395,7 +395,7 @@ ldap_set_option( case LDAP_OPT_NETWORK_TIMEOUT: { const struct timeval *tv = - (struct timeval *) invalue; + (const struct timeval *) invalue; if ( lo->ldo_tm_net != NULL ) { LDAP_FREE( lo->ldo_tm_net ); diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index cf56ae8a64..42460cccec 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -73,7 +73,7 @@ ldap_int_timeval_dup( struct timeval **dest, const struct timeval *src ) return 1; } - SAFEMEMCPY( (char *) new, (char *) src, sizeof(struct timeval)); + SAFEMEMCPY( (char *) new, (const char *) src, sizeof(struct timeval)); *dest = new; return 0; diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index d85f4e790a..988bac7d45 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -86,13 +86,13 @@ skip_url_prefix( * return non-zero if this looks like a LDAP URL; zero if not * if non-zero returned, *urlp will be moved past "ldap://" part of URL */ - char* p; + const char *p; if ( url == NULL ) { return( NULL ); } - p = (char *) url; + p = url; /* skip leading '<' (if any) */ if ( *p == '<' ) { diff --git a/libraries/libldif/line64.c b/libraries/libldif/line64.c index de965e5421..49c884b4e2 100644 --- a/libraries/libldif/line64.c +++ b/libraries/libldif/line64.c @@ -290,7 +290,7 @@ ldif_sput( LDAP_CONST char *val, ber_len_t vlen ) { - unsigned char *byte, *stop; + const unsigned char *byte, *stop; unsigned char buf[3]; unsigned long bits; char *save; @@ -391,7 +391,7 @@ ldif_sput( return; } - stop = (unsigned char *) (val + vlen); + stop = (const unsigned char *) (val + vlen); if ( type == LDIF_PUT_VALUE && isgraph( val[0] ) && val[0] != ':' && val[0] != '<' @@ -401,7 +401,7 @@ ldif_sput( ) { int b64 = 0; - for ( byte = (unsigned char *) val; byte < stop; + for ( byte = (const unsigned char *) val; byte < stop; byte++, len++ ) { if ( !isascii( *byte ) || !isprint( *byte ) ) { @@ -428,7 +428,7 @@ ldif_sput( len = savelen + 2; /* convert to base 64 (3 bytes => 4 base 64 digits) */ - for ( byte = (unsigned char *) val; + for ( byte = (const unsigned char *) val; byte < stop - 2; byte += 3 ) {