From: Hallvard Furuseth Date: Tue, 13 Jul 1999 05:17:50 +0000 (+0000) Subject: constify use of invalue in _set_option() X-Git-Tag: OPENLDAP_REL_ENG_2_BP~170 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=96e8fafb5165efe93b25bad80a764fffddcbb061;p=openldap constify use of invalue in _set_option() --- diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c index c8a53dfc9c..160aac597d 100644 --- a/libraries/liblber/options.c +++ b/libraries/liblber/options.c @@ -76,7 +76,8 @@ ber_set_option( && ( option == LBER_OPT_MEMORY_FNS ) && ( invalue != NULL )) { - BerMemoryFunctions *f = (BerMemoryFunctions *) invalue; + const BerMemoryFunctions *f = + (const BerMemoryFunctions *) invalue; /* make sure all functions are provided */ if(!( f->bmf_malloc && f->bmf_calloc @@ -107,7 +108,7 @@ ber_set_option( if(item == NULL) { if(option == LBER_OPT_BER_DEBUG) { - ber_int_debug = * (int *) invalue; + ber_int_debug = * (const int *) invalue; return LBER_OPT_SUCCESS; } else if(option == LBER_OPT_LOG_PRINT_FN) { @@ -124,12 +125,12 @@ ber_set_option( switch(option) { case LBER_OPT_BER_OPTIONS: assert( BER_VALID( ber ) ); - ber->ber_options = * (int *) invalue; + ber->ber_options = * (const int *) invalue; return LBER_OPT_SUCCESS; case LBER_OPT_BER_DEBUG: assert( BER_VALID( ber ) ); - ber->ber_debug = * (int *) invalue; + ber->ber_debug = * (const int *) invalue; return LBER_OPT_SUCCESS; default: diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index ef19dfda61..b41cdadf7f 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -330,19 +330,19 @@ ldap_set_option( break; case LDAP_OPT_DEREF: - lo->ldo_deref = * (int *) invalue; + lo->ldo_deref = * (const int *) invalue; return LDAP_OPT_SUCCESS; case LDAP_OPT_SIZELIMIT: - lo->ldo_sizelimit = * (int *) invalue; + lo->ldo_sizelimit = * (const int *) invalue; return LDAP_OPT_SUCCESS; case LDAP_OPT_TIMELIMIT: - lo->ldo_timelimit = * (int *) invalue; + lo->ldo_timelimit = * (const int *) invalue; return LDAP_OPT_SUCCESS; case LDAP_OPT_PROTOCOL_VERSION: { - int vers = * (int *) invalue; + int vers = * (const int *) invalue; if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) { /* not supported */ break; @@ -351,7 +351,8 @@ ldap_set_option( } return LDAP_OPT_SUCCESS; case LDAP_OPT_SERVER_CONTROLS: { - LDAPControl **controls = (LDAPControl **) invalue; + LDAPControl *const *controls = + (LDAPControl *const *) invalue; ldap_controls_free( lo->ldo_sctrls ); @@ -360,8 +361,7 @@ ldap_set_option( return LDAP_OPT_SUCCESS; } - lo->ldo_sctrls = - ldap_controls_dup( (LDAPControl **) invalue ); + lo->ldo_sctrls = ldap_controls_dup( controls ); if(lo->ldo_sctrls == NULL) { /* memory allocation error ? */ @@ -370,7 +370,8 @@ ldap_set_option( } return LDAP_OPT_SUCCESS; case LDAP_OPT_CLIENT_CONTROLS: { - LDAPControl **controls = (LDAPControl **) invalue; + LDAPControl *const *controls = + (LDAPControl *const *) invalue; ldap_controls_free( lo->ldo_cctrls ); @@ -379,8 +380,7 @@ ldap_set_option( return LDAP_OPT_SUCCESS; } - lo->ldo_cctrls = - ldap_controls_dup( (LDAPControl **) invalue ); + lo->ldo_cctrls = ldap_controls_dup( controls ); if(lo->ldo_cctrls == NULL) { /* memory allocation error ? */ @@ -389,7 +389,7 @@ ldap_set_option( } return LDAP_OPT_SUCCESS; case LDAP_OPT_HOST_NAME: { - char* host = (char *) invalue; + const char *host = (const char *) invalue; if(lo->ldo_defhost != NULL) { LDAP_FREE(lo->ldo_defhost); @@ -419,7 +419,7 @@ ldap_set_option( } return LDAP_OPT_SUCCESS; case LDAP_OPT_ERROR_NUMBER: { - int err = * (int *) invalue; + int err = * (const int *) invalue; if(ld == NULL) { /* need a struct ldap */ @@ -430,7 +430,7 @@ ldap_set_option( } return LDAP_OPT_SUCCESS; case LDAP_OPT_ERROR_STRING: { - char* err = (char *) invalue; + const char *err = (const char *) invalue; if(ld == NULL) { /* need a struct ldap */ @@ -445,7 +445,7 @@ ldap_set_option( } return LDAP_OPT_SUCCESS; case LDAP_OPT_MATCHED_DN: { - char* err = (char *) invalue; + const char *err = (const char *) invalue; if(ld == NULL) { /* need a struct ldap */ @@ -464,7 +464,7 @@ ldap_set_option( break; case LDAP_OPT_DEBUG_LEVEL: - lo->ldo_debug = * (int *) invalue; + lo->ldo_debug = * (const int *) invalue; return LDAP_OPT_SUCCESS; default: