From a4e3706e1f1c49ee8a461ee4433fb0f4d7ee1bfb Mon Sep 17 00:00:00 2001 From: Quanah Gibson-Mount Date: Sat, 8 Nov 2008 02:15:17 +0000 Subject: [PATCH] Warnings cleanup --- clients/tools/common.c | 6 +-- clients/tools/ldapsearch.c | 6 +-- libraries/libldap/abandon.c | 3 +- libraries/libldap/ldap_sync.c | 2 +- libraries/libldap/request.c | 4 +- libraries/liblutil/passwd.c | 4 +- libraries/liblutil/utils.c | 2 +- servers/slapd/aci.c | 2 +- servers/slapd/alock.c | 2 +- servers/slapd/attr.c | 3 +- servers/slapd/back-bdb/add.c | 2 +- servers/slapd/back-bdb/back-bdb.h | 2 +- servers/slapd/back-bdb/cache.c | 2 +- servers/slapd/back-bdb/delete.c | 2 +- servers/slapd/back-bdb/modify.c | 2 +- servers/slapd/back-bdb/modrdn.c | 2 +- servers/slapd/back-bdb/monitor.c | 4 +- servers/slapd/back-bdb/tools.c | 3 +- servers/slapd/back-ldif/ldif.c | 4 +- servers/slapd/back-meta/bind.c | 4 +- servers/slapd/back-meta/config.c | 4 +- servers/slapd/component.c | 2 +- servers/slapd/dn.c | 2 +- servers/slapd/entry.c | 4 +- servers/slapd/mods.c | 12 ++--- servers/slapd/mr.c | 2 +- servers/slapd/overlays/accesslog.c | 12 ++--- servers/slapd/overlays/dynlist.c | 2 +- servers/slapd/overlays/pcache.c | 8 +-- servers/slapd/overlays/ppolicy.c | 4 +- servers/slapd/result.c | 2 +- servers/slapd/sasl.c | 12 ++--- servers/slapd/saslauthz.c | 2 +- servers/slapd/schema_init.c | 87 +++++++++++++++--------------- servers/slapd/search.c | 2 +- servers/slapd/slapi/slapi_pblock.c | 2 +- servers/slapd/slapi/slapi_utils.c | 4 +- servers/slapd/syncrepl.c | 8 +-- servers/slapd/value.c | 6 +-- 39 files changed, 119 insertions(+), 119 deletions(-) diff --git a/clients/tools/common.c b/clients/tools/common.c index 86434283d8..d468dd9969 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -625,7 +625,7 @@ tool_args( int argc, char **argv ) (unsigned char *)bv.bv_val, bv.bv_len ); - if ( retcode == -1 || retcode > bv.bv_len ) { + if ( retcode == -1 || (unsigned) retcode > bv.bv_len ) { fprintf( stderr, "Unable to parse value of general control %s\n", control ); usage(); @@ -1310,7 +1310,7 @@ tool_bind( LDAP *ld ) sctrlsp = sctrls; } - assert( nsctrls < sizeof(sctrls)/sizeof(sctrls[0]) ); + assert( nsctrls < (int) (sizeof(sctrls)/sizeof(sctrls[0])) ); if ( authmethod == LDAP_AUTH_SASL ) { #ifdef HAVE_CYRUS_SASL @@ -1523,7 +1523,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count ) ber_init2( ber, NULL, LBER_USE_DER ); - if ( ber_printf( ber, "s", proxydn ) == LBER_ERROR ) { + if ( ber_printf( ber, "s", proxydn ) == -1 ) { exit( EXIT_FAILURE ); } diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 43d4b5ff0e..04bbc725b0 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -856,13 +856,13 @@ getNextPage: &sync_cookie ); } - if ( err == LBER_ERROR ) { + if ( err == -1 ) { ber_free( syncber, 1 ); fprintf( stderr, _("ldap sync control encoding error!\n") ); return EXIT_FAILURE; } - if ( ber_flatten( syncber, &syncbvalp ) == LBER_ERROR ) { + if ( ber_flatten( syncber, &syncbvalp ) == -1 ) { return EXIT_FAILURE; } @@ -1618,7 +1618,7 @@ static int print_result( tool_write_ldif( LDIF_PUT_TEXT, "text", line, - next ? next - line : strlen( line ) ); + next ? (size_t) (next - line) : strlen( line )); line = next ? next + 1 : NULL; } diff --git a/libraries/libldap/abandon.c b/libraries/libldap/abandon.c index 8f2fb34194..bd9ebb3818 100644 --- a/libraries/libldap/abandon.c +++ b/libraries/libldap/abandon.c @@ -447,8 +447,7 @@ int ldap_int_bisect_delete( ber_int_t **vp, ber_len_t *np, int id, int idx ) { ber_int_t *v; - ber_len_t n; - int i; + ber_len_t i, n; assert( vp != NULL ); assert( np != NULL ); diff --git a/libraries/libldap/ldap_sync.c b/libraries/libldap/ldap_sync.c index 6e7cd48084..da699ff3ee 100644 --- a/libraries/libldap/ldap_sync.c +++ b/libraries/libldap/ldap_sync.c @@ -691,7 +691,7 @@ ldap_sync_init( ldap_sync_t *ls, int mode ) rc ? "!!! " : "", rc ); #endif /* LDAP_SYNC_TRACE */ - if ( rc == LBER_ERROR ) { + if ( rc < 0 ) { rc = LDAP_OTHER; goto done; } diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 8030411886..e6b695a644 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -1099,7 +1099,7 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * /* See if we've already requested this DN with this conn */ LDAPRequest *lp; int looped = 0; - int len = srv->lud_dn ? strlen( srv->lud_dn ) : 0; + ber_len_t len = srv->lud_dn ? strlen( srv->lud_dn ) : 0; for ( lp = origreq; lp; ) { if ( lp->lr_conn == lc && len == lp->lr_dn.bv_len @@ -1358,7 +1358,7 @@ ldap_chase_referrals( LDAP *ld, if (( lc = find_connection( ld, srv, 1 )) != NULL ) { LDAPRequest *lp; int looped = 0; - int len = srv->lud_dn ? strlen( srv->lud_dn ) : 0; + ber_len_t len = srv->lud_dn ? strlen( srv->lud_dn ) : 0; for ( lp = lr; lp; lp = lp->lr_parent ) { if ( lp->lr_conn == lc && len == lp->lr_dn.bv_len ) diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index 8dd59f9084..9f2559917e 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -716,7 +716,7 @@ static int chk_lanman( const struct berval *cred, const char **text ) { - int i; + ber_len_t i; char UcasePassword[15]; des_cblock key; des_key_schedule schedule; @@ -1003,7 +1003,7 @@ static int hash_lanman( const char **text ) { - int i; + ber_len_t i; char UcasePassword[15]; des_cblock key; des_key_schedule schedule; diff --git a/libraries/liblutil/utils.c b/libraries/liblutil/utils.c index ff37d417a0..afda235d81 100644 --- a/libraries/liblutil/utils.c +++ b/libraries/liblutil/utils.c @@ -940,7 +940,7 @@ lutil_snprintf( char *buf, ber_len_t bufsize, char **next, ber_len_t *len, LDAP_ *len = ret; } - if ( ret >= bufsize ) { + if ( (unsigned) ret >= bufsize ) { if ( next ) { *next = &buf[ bufsize - 1 ]; } diff --git a/servers/slapd/aci.c b/servers/slapd/aci.c index de0b6c6ac3..88232f33e5 100644 --- a/servers/slapd/aci.c +++ b/servers/slapd/aci.c @@ -1043,7 +1043,7 @@ static int OpenLDAPaciValidatePerms( struct berval *perms ) { - int i; + ber_len_t i; for ( i = 0; i < perms->bv_len; ) { switch ( perms->bv_val[ i ] ) { diff --git a/servers/slapd/alock.c b/servers/slapd/alock.c index 3d091bf60f..1a50a399f1 100644 --- a/servers/slapd/alock.c +++ b/servers/slapd/alock.c @@ -178,7 +178,7 @@ alock_read_iattr ( unsigned char * bufptr ) assert (bufptr != NULL); bufptr += sizeof (unsigned long int); - for (count=0; count <= sizeof (unsigned long int); ++count) { + for (count=0; count <= (int) sizeof (unsigned long int); ++count) { val <<= 8; val += (unsigned long int) *bufptr--; } diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 67c26911c2..4d578d9247 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -213,7 +213,7 @@ attr_dup2( Attribute *tmp, Attribute *a ) { tmp->a_flags = a->a_flags & SLAP_ATTR_PERSISTENT_FLAGS; if ( a->a_vals != NULL ) { - int i; + unsigned i, j; tmp->a_numvals = a->a_numvals; tmp->a_vals = ch_malloc( (tmp->a_numvals + 1) * sizeof(struct berval) ); @@ -228,7 +228,6 @@ attr_dup2( Attribute *tmp, Attribute *a ) assert( a->a_nvals != NULL ); if ( a->a_nvals != a->a_vals ) { - int j; tmp->a_nvals = ch_malloc( (tmp->a_numvals + 1) * sizeof(struct berval) ); for ( j = 0; !BER_BVISNULL( &a->a_nvals[j] ); j++ ) { diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index d6fba1bdd2..cea8a0be4c 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -34,7 +34,7 @@ bdb_add(Operation *op, SlapReply *rs ) AttributeDescription *entry = slap_schema.si_ad_entry; DB_TXN *ltid = NULL, *lt2, *rtxn; ID eid = NOID; - struct bdb_op_info opinfo = {0}; + struct bdb_op_info opinfo = {{{ 0 }}}; int subentry; DB_LOCK lock; diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 19c30cc5e1..6493a4583c 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -332,7 +332,7 @@ extern int __db_logmsg(const DB_ENV *env, DB_TXN *txn, const char *op, u_int32_t /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */ #define BDB_DISK2ID( src, dst ) \ - do { int i0; ID tmp = 0; unsigned char *_p; \ + do { unsigned i0; ID tmp = 0; unsigned char *_p; \ _p = (unsigned char *)(src); \ for ( i0=0; i0= bdb->bi_cache.c_minfree ) { + if ( (unsigned) count >= bdb->bi_cache.c_minfree ) { ldap_pvt_thread_mutex_lock( &bdb->bi_cache.c_count_mutex ); bdb->bi_cache.c_cursize -= count; ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.c_count_mutex ); diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index b6a33e234c..5979e7cbcd 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -35,7 +35,7 @@ bdb_delete( Operation *op, SlapReply *rs ) AttributeDescription *children = slap_schema.si_ad_children; AttributeDescription *entry = slap_schema.si_ad_entry; DB_TXN *ltid = NULL, *lt2; - struct bdb_op_info opinfo = {0}; + struct bdb_op_info opinfo = {{{ 0 }}}; ID eid; DB_LOCK lock, plock; diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index cf44b7d9e5..0ae77b443e 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -330,7 +330,7 @@ bdb_modify( Operation *op, SlapReply *rs ) char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof textbuf; DB_TXN *ltid = NULL, *lt2; - struct bdb_op_info opinfo = {0}; + struct bdb_op_info opinfo = {{{ 0 }}}; Entry dummy = {0}; int fakeroot = 0; diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index c93897525a..42a00f0136 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -36,7 +36,7 @@ bdb_modrdn( Operation *op, SlapReply *rs ) char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof textbuf; DB_TXN *ltid = NULL, *lt2; - struct bdb_op_info opinfo = {0}; + struct bdb_op_info opinfo = {{{ 0 }}}; Entry dummy = {0}; Entry *np = NULL; /* newSuperior Entry */ diff --git a/servers/slapd/back-bdb/monitor.c b/servers/slapd/back-bdb/monitor.c index 7421cb1cd4..5f7134043b 100644 --- a/servers/slapd/back-bdb/monitor.c +++ b/servers/slapd/back-bdb/monitor.c @@ -551,9 +551,9 @@ bdb_monitor_bitmask2key( slap_mask_t bitmask ) { int key; - for ( key = 0; key < 8*sizeof(slap_mask_t) && !( bitmask & 0x1U ); key++ ) { + for ( key = 0; key < 8 * (int)sizeof(slap_mask_t) && !( bitmask & 0x1U ); + key++ ) bitmask >>= 1; - } return key; } diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index eb09962c78..66b2e9a32f 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -395,13 +395,12 @@ static int bdb_tool_next_id( holes[nholes++].id = e->e_id; } } else if ( !hole ) { - unsigned i; + unsigned i, j; e->e_id = ei->bei_id; for ( i=0; ie_id ) { - int j; free(holes[i].dn.bv_val); for (j=i;jo_ctrls ) { for ( n = 0; op->o_ctrls[ n ]; n++ ) diff --git a/servers/slapd/back-meta/config.c b/servers/slapd/back-meta/config.c index 610f607545..5a3b3d82ce 100644 --- a/servers/slapd/back-meta/config.c +++ b/servers/slapd/back-meta/config.c @@ -1082,7 +1082,9 @@ idassert-authzFrom "dn:" return 1; } - if ( snprintf( binddn, sizeof( binddn ), "binddn=%s", argv[ 1 ] ) >= sizeof( binddn ) ) { + if ( sizeof( binddn ) <= (unsigned) snprintf( binddn, + sizeof( binddn ), "binddn=%s", argv[ 1 ] )) + { Debug( LDAP_DEBUG_ANY, "%s: line %d: \"pseudorootdn\" too long.\n", fname, lineno, 0 ); return 1; diff --git a/servers/slapd/component.c b/servers/slapd/component.c index d950e2ae8a..9bc69405b4 100644 --- a/servers/slapd/component.c +++ b/servers/slapd/component.c @@ -212,7 +212,7 @@ dup_comp_filter_list ( int get_len_of_next_assert_value ( struct berval* bv, char separator ) { - int i = 0; + ber_len_t i = 0; while (1) { if ( (bv->bv_val[ i ] == separator) || ( i >= bv->bv_len) ) break; diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 95520700e3..98eeebc417 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -1077,7 +1077,7 @@ dn_rdnlen( p = ber_bvchr( dn_in, ',' ); - return p ? p - dn_in->bv_val : dn_in->bv_len; + return p ? (ber_len_t) (p - dn_in->bv_val) : dn_in->bv_len; } diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index fa30a1ee69..289a0f4d09 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -725,8 +725,8 @@ ber_len_t entry_flatsize(Entry *e, int norm) */ int entry_encode(Entry *e, struct berval *bv) { - ber_len_t len, dnlen, ndnlen; - int i, nattrs, nvals; + ber_len_t len, dnlen, ndnlen, i; + int nattrs, nvals; Attribute *a; unsigned char *ptr; diff --git a/servers/slapd/mods.c b/servers/slapd/mods.c index 820ed298f6..22b9e33651 100644 --- a/servers/slapd/mods.c +++ b/servers/slapd/mods.c @@ -59,7 +59,7 @@ modify_add_values( /* FIXME: Catch old code that doesn't set sm_numvals. */ if ( !BER_BVISNULL( &mod->sm_values[mod->sm_numvals] )) { - int i; + unsigned i; for ( i = 0; !BER_BVISNULL( &mod->sm_values[i] ); i++ ); assert( mod->sm_numvals == i ); } @@ -69,8 +69,8 @@ modify_add_values( if ( a != NULL ) { MatchingRule *mr; struct berval *cvals; - int rc, i, p; - unsigned flags; + int rc; + unsigned i, p, flags; mr = mod->sm_desc->ad_type->sat_equality; if( mr == NULL || !mr->smr_match ) { @@ -116,7 +116,7 @@ modify_add_values( /* value already exists */ *text = textbuf; snprintf( textbuf, textlen, - "modify/%s: %s: value #%d already exists", + "modify/%s: %s: value #%u already exists", op, mod->sm_desc->ad_cname.bv_val, i ); return LDAP_TYPE_OR_VALUE_EXISTS; } @@ -196,8 +196,8 @@ modify_delete_vindex( MatchingRule *mr = mod->sm_desc->ad_type->sat_equality; struct berval *cvals; int *id2 = NULL; - int i, j, rc = 0; - unsigned flags; + int rc = 0; + unsigned i, j, flags; char dummy = '\0'; /* diff --git a/servers/slapd/mr.c b/servers/slapd/mr.c index 91756a2d01..355191491c 100644 --- a/servers/slapd/mr.c +++ b/servers/slapd/mr.c @@ -377,7 +377,7 @@ matching_rule_use_init( void ) LDAP_SLIST_FOREACH( mr, &mr_list, smr_next ) { AttributeType *at; - MatchingRuleUse mru_storage = { 0 }, + MatchingRuleUse mru_storage = {{ 0 }}, *mru = &mru_storage; char **applies_oids = NULL; diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c index 866afd7937..0be32e9bfa 100644 --- a/servers/slapd/overlays/accesslog.c +++ b/servers/slapd/overlays/accesslog.c @@ -534,17 +534,17 @@ log_age_unparse( int age, struct berval *agebv, size_t size ) if ( dd ) { len = snprintf( ptr, size, "%d+", dd ); - assert( len >= 0 && len < size ); + assert( len >= 0 && (unsigned) len < size ); size -= len; ptr += len; } len = snprintf( ptr, size, "%02d:%02d", hh, mm ); - assert( len >= 0 && len < size ); + assert( len >= 0 && (unsigned) len < size ); size -= len; ptr += len; if ( ss ) { len = snprintf( ptr, size, ":%02d", ss ); - assert( len >= 0 && len < size ); + assert( len >= 0 && (unsigned) len < size ); size -= len; ptr += len; } @@ -580,7 +580,7 @@ log_old_lookup( Operation *op, SlapReply *rs ) a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryCSN ); if ( a ) { - int len = a->a_vals[0].bv_len; + ber_len_t len = a->a_vals[0].bv_len; if ( len > pd->csn.bv_len ) len = pd->csn.bv_len; if ( memcmp( a->a_vals[0].bv_val, pd->csn.bv_val, len ) > 0 ) { @@ -933,7 +933,7 @@ logSchemaControlValidate( struct berval *valp ) { struct berval val, bv; - int i; + ber_len_t i; int rc = LDAP_SUCCESS; assert( valp != NULL ); @@ -1155,7 +1155,7 @@ accesslog_ctrls( } if ( !BER_BVISNULL( &ctrls[ i ]->ldctl_value ) ) { - int j; + ber_len_t j; ptr = lutil_strcopy( ptr, " controlValue \"" ); for ( j = 0; j < ctrls[ i ]->ldctl_value.bv_len; j++ ) diff --git a/servers/slapd/overlays/dynlist.c b/servers/slapd/overlays/dynlist.c index 5a5eb09f39..b7f38aa01d 100644 --- a/servers/slapd/overlays/dynlist.c +++ b/servers/slapd/overlays/dynlist.c @@ -877,7 +877,7 @@ dynlist_build_def_filter( dynlist_info_t *dli ) ptr = lutil_strcopy( ptr, dli->dli_oc->soc_cname.bv_val ); ptr = lutil_strcopy( ptr, "))" ); - assert( dli->dli_default_filter.bv_len == ptr - dli->dli_default_filter.bv_val ); + assert( ptr == &dli->dli_default_filter.bv_val[dli->dli_default_filter.bv_len] ); return 0; } diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 40ac4b99ed..ea01254d18 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -1697,7 +1697,7 @@ pcache_remove_entries_from_cache( Filter f = { 0 }; char filtbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE + STRLENOF( "(entryUUID=)" ) ]; AttributeAssertion ava = ATTRIBUTEASSERTION_INIT; - AttributeName attrs[ 2 ] = { 0 }; + AttributeName attrs[ 2 ] = {{{ 0 }}}; int s, rc; if ( op == NULL ) { @@ -1812,7 +1812,7 @@ pcache_remove_entry_queries_from_cache( Filter f = { 0 }; char filter_str[ LDAP_LUTIL_UUIDSTR_BUFSIZE + STRLENOF( "(queryId=)" ) ]; AttributeAssertion ava = ATTRIBUTEASSERTION_INIT; - AttributeName attrs[ 2 ] = { 0 }; + AttributeName attrs[ 2 ] = {{{ 0 }}}; int rc; BerVarray vals = NULL; @@ -3258,7 +3258,7 @@ pcache_db_open2( BerVarray vals = NULL; Filter f = { 0 }, f2 = { 0 }; AttributeAssertion ava = ATTRIBUTEASSERTION_INIT; - AttributeName attrs[ 2 ] = { 0 }; + AttributeName attrs[ 2 ] = {{{ 0 }}}; connection_fake_init( &conn, &opbuf, thrctx ); op = &opbuf.ob_op; @@ -3424,7 +3424,7 @@ pcache_db_close( slap_callback cb = { 0 }; SlapReply rs = { REP_RESULT }; - Modifications mod = { 0 }; + Modifications mod = {{ 0 }}; thrctx = ldap_pvt_thread_pool_context(); diff --git a/servers/slapd/overlays/ppolicy.c b/servers/slapd/overlays/ppolicy.c index 99db2bd5b1..ca0cb29b14 100644 --- a/servers/slapd/overlays/ppolicy.c +++ b/servers/slapd/overlays/ppolicy.c @@ -395,7 +395,7 @@ create_passcontrol( Operation *op, int exptime, int grace, LDAPPasswordPolicyErr } ber_printf( ber, /*{*/ "N}" ); - if (ber_flatten2( ber, &(c.ldctl_value), 1 ) == LBER_DEFAULT) { + if (ber_flatten2( ber, &(c.ldctl_value), 1 ) == -1) { return NULL; } (void)ber_free_buf(ber); @@ -679,7 +679,7 @@ parse_pwdhistory( struct berval *bv, char **oid, time_t *oldtime, struct berval { char *ptr; struct berval nv, npw; - int i, j; + ber_len_t i, j; assert (bv && (bv->bv_len > 0) && (bv->bv_val) && oldtime && oldpw ); diff --git a/servers/slapd/result.c b/servers/slapd/result.c index f89b87304c..2912143dd4 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -1546,7 +1546,7 @@ int slap_read_controls( rc = ber_flatten2( ber, &c.ldctl_value, 0 ); - if( rc == LBER_ERROR ) return LDAP_OTHER; + if( rc == -1 ) return LDAP_OTHER; c.ldctl_oid = oid->bv_val; c.ldctl_iscritical = 0; diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index b73258e66d..0a300fa879 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -117,7 +117,7 @@ slap_sasl_log( } Debug( level, "SASL [conn=%ld] %s: %s\n", - conn ? conn->c_connid: -1, + conn ? (long) conn->c_connid: -1L, label, message ); @@ -554,7 +554,7 @@ slap_sasl_canonicalize( *out_len = 0; Debug( LDAP_DEBUG_ARGS, "SASL Canonicalize [conn=%ld]: %s=\"%s\"\n", - conn ? conn->c_connid : -1, + conn ? (long) conn->c_connid : -1L, (flags & SASL_CU_AUTHID) ? "authcid" : "authzid", in ? in : ""); @@ -636,7 +636,7 @@ slap_sasl_canonicalize( prop_set( props, names[0], dn.bv_val, dn.bv_len ); Debug( LDAP_DEBUG_ARGS, "SASL Canonicalize [conn=%ld]: %s=\"%s\"\n", - conn ? conn->c_connid : -1, names[0]+1, + conn ? (long) conn->c_connid : -1L, names[0]+1, dn.bv_val ? dn.bv_val : "" ); /* Not needed any more, SASL has copied it */ @@ -679,7 +679,7 @@ slap_sasl_authorize( Debug( LDAP_DEBUG_ARGS, "SASL proxy authorize [conn=%ld]: " "authcid=\"%s\" authzid=\"%s\"\n", - conn ? conn->c_connid : -1, auth_identity, requested_user ); + conn ? (long) conn->c_connid : -1L, auth_identity, requested_user ); if ( conn->c_sasl_dn.bv_val ) { BER_BVZERO( &conn->c_sasl_dn ); } @@ -709,7 +709,7 @@ slap_sasl_authorize( if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "SASL Proxy Authorize [conn=%ld]: " "proxy authorization disallowed (%d)\n", - (long) (conn ? conn->c_connid : -1), rc, 0 ); + conn ? (long) conn->c_connid : -1L, rc, 0 ); sasl_seterror( sconn, 0, "not authorized" ); return SASL_NOAUTHZ; @@ -729,7 +729,7 @@ ok: Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " " proxy authorization allowed authzDN=\"%s\"\n", - (long) (conn ? conn->c_connid : -1), + conn ? (long) conn->c_connid : -1L, authzDN.bv_val ? authzDN.bv_val : "", 0 ); return SASL_OK; } diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index 08c7c690f5..0d98d86b6a 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -1699,7 +1699,7 @@ exact_match: /* leave room for at least one char of attributeType, * one for '=' and one for ',' */ - if ( d < STRLENOF( "x=,") ) { + if ( d < (int) STRLENOF( "x=,") ) { goto CONCLUDED; } diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 9f5e88e7b5..27bcb72824 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -1543,8 +1543,8 @@ UTF8StringNormalize( void *ctx ) { struct berval tmp, nvalue; - int flags; - int i, wasspace; + int flags, wasspace; + ber_len_t i; assert( SLAP_MR_IS_VALUE_OF_SYNTAX( use ) != 0 ); @@ -1619,7 +1619,7 @@ directoryStringSubstringsMatch( int match = 0; SubstringsAssertion *sub = assertedValue; struct berval left = *value; - int i; + ber_len_t i; int priorspace=0; if ( !BER_BVISNULL( &sub->sa_initial ) ) { @@ -2008,7 +2008,7 @@ postalAddressValidate( struct berval *in ) { struct berval bv = *in; - int c; + ber_len_t c; for ( c = 0; c < in->bv_len; c++ ) { if ( in->bv_val[c] == '\\' ) { @@ -2044,7 +2044,7 @@ postalAddressNormalize( void *ctx ) { BerVarray lines = NULL, nlines = NULL; - int l, c; + ber_len_t l, c; int rc = LDAP_SUCCESS; MatchingRule *xmr = NULL; char *p; @@ -2101,7 +2101,7 @@ postalAddressNormalize( } *--p = '\0'; - assert( p - normalized->bv_val == normalized->bv_len ); + assert( p == &normalized->bv_val[normalized->bv_len] ); done:; if ( nlines != NULL ) { @@ -2851,9 +2851,8 @@ static int checkNum( struct berval *in, struct berval *out ) { /* parse serialNumber */ - int neg = 0; + ber_len_t neg = 0, extra = 0; char first = '\0'; - int extra = 0; out->bv_val = in->bv_val; out->bv_len = 0; @@ -2911,7 +2910,7 @@ serialNumberAndIssuerCheck( struct berval *is, void *ctx ) { - int n; + ber_len_t n; if( in->bv_len < 3 ) return LDAP_INVALID_SYNTAX; @@ -3059,7 +3058,7 @@ serialNumberAndIssuerCheck( ber_dupbv_x( &ni, is, ctx ); } else { - ber_int_t src, dst; + ber_len_t src, dst; ni.bv_len = is->bv_len - numdquotes; ni.bv_val = ber_memalloc_x( ni.bv_len + 1, ctx ); @@ -3164,7 +3163,7 @@ serialNumberAndIssuerPretty( p = lutil_strncopy( p, ni.bv_val, ni.bv_len ); p = lutil_strcopy( p, /*{*/ "\" }" ); - assert( p - out->bv_val == out->bv_len ); + assert( p == &out->bv_val[out->bv_len] ); done:; Debug( LDAP_DEBUG_TRACE, "<<< serialNumberAndIssuerPretty: <%s> => <%s>\n", @@ -3186,8 +3185,7 @@ slap_bin2hex( unsigned char *ptr, zero = '\0'; char *sptr; int first; - int i; - ber_len_t len, nlen; + ber_len_t i, len, nlen; assert( in != NULL ); assert( !BER_BVISNULL( in ) ); @@ -3240,7 +3238,7 @@ slap_bin2hex( *sptr++ = 'H'; *sptr = '\0'; - assert( sptr - out->bv_val == nlen ); + assert( sptr == &out->bv_val[nlen] ); out->bv_len = nlen; @@ -3327,7 +3325,7 @@ serialNumberAndIssuerNormalize( p = lutil_strncopy( p, ni.bv_val, ni.bv_len ); p = lutil_strcopy( p, /*{*/ "\" }" ); - assert( p - out->bv_val == out->bv_len ); + assert( p == &out->bv_val[out->bv_len] ); func_leave: Debug( LDAP_DEBUG_TRACE, "<<< serialNumberAndIssuerNormalize: <%s> => <%s>\n", @@ -3440,7 +3438,8 @@ done: static int checkTime( struct berval *in, struct berval *out ) { - int i; + int rc; + ber_len_t i; char buf[STRLENOF("YYYYmmddHHMMSSZ") + 1]; struct berval bv; @@ -3493,12 +3492,12 @@ checkTime( struct berval *in, struct berval *out ) return -1; } - i = generalizedTimeValidate( NULL, &bv ); - if ( i == LDAP_SUCCESS && out != NULL ) { + rc = generalizedTimeValidate( NULL, &bv ); + if ( rc == LDAP_SUCCESS && out != NULL ) { out->bv_len = bv.bv_len; } - return i != LDAP_SUCCESS; + return rc != LDAP_SUCCESS; } static int @@ -3645,7 +3644,7 @@ issuerAndThisUpdateCheck( ber_dupbv_x( &ni, is, ctx ); } else { - ber_int_t src, dst; + ber_len_t src, dst; ni.bv_len = is->bv_len - numdquotes; ni.bv_val = ber_memalloc_x( ni.bv_len + 1, ctx ); @@ -3752,7 +3751,7 @@ issuerAndThisUpdatePretty( p = lutil_strncopy( p, tu.bv_val, tu.bv_len ); p = lutil_strcopy( p, /*{*/ "\" }" ); - assert( p - out->bv_val == out->bv_len ); + assert( p == &out->bv_val[out->bv_len] ); done:; Debug( LDAP_DEBUG_TRACE, "<<< issuerAndThisUpdatePretty: <%s> => <%s>\n", @@ -3818,7 +3817,7 @@ issuerAndThisUpdateNormalize( p = lutil_strncopy( p, tu2.bv_val, tu2.bv_len ); p = lutil_strcopy( p, /*{*/ "\" }" ); - assert( p - out->bv_val == out->bv_len ); + assert( p == & out->bv_val[out->bv_len] ); func_leave: Debug( LDAP_DEBUG_TRACE, "<<< issuerAndThisUpdateNormalize: <%s> => <%s>\n", @@ -3929,7 +3928,7 @@ hexValidate( Syntax *syntax, struct berval *in ) { - int i; + ber_len_t i; assert( in != NULL ); assert( !BER_BVISNULL( in ) ); @@ -3954,7 +3953,7 @@ hexNormalize( struct berval *normalized, void *ctx ) { - int i; + ber_len_t i; assert( val != NULL ); assert( normalized != NULL ); @@ -4045,7 +4044,7 @@ csnSidNormalize( assert( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) != 0 ); ptr = ber_bvchr( val, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4053,7 +4052,7 @@ csnSidNormalize( bv.bv_len = val->bv_len - ( ptr + 1 - val->bv_val ); ptr = ber_bvchr( &bv, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4061,7 +4060,7 @@ csnSidNormalize( bv.bv_len = val->bv_len - ( ptr + 1 - val->bv_val ); ptr = ber_bvchr( &bv, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4100,7 +4099,7 @@ csnValidate( bv = *in; ptr = ber_bvchr( &bv, '#' ); - if ( ptr == NULL || ptr - bv.bv_val == bv.bv_len ) { + if ( ptr == NULL || ptr == &bv.bv_val[bv.bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4120,7 +4119,7 @@ csnValidate( bv.bv_len = in->bv_len - ( bv.bv_val - in->bv_val ); ptr = ber_bvchr( &bv, '#' ); - if ( ptr == NULL || ptr - in->bv_val == in->bv_len ) { + if ( ptr == NULL || ptr == &in->bv_val[in->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4138,7 +4137,7 @@ csnValidate( bv.bv_len = in->bv_len - ( bv.bv_val - in->bv_val ); ptr = ber_bvchr( &bv, '#' ); - if ( ptr == NULL || ptr - in->bv_val == in->bv_len ) { + if ( ptr == NULL || ptr == &in->bv_val[in->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4178,7 +4177,7 @@ csnNormalize21( struct berval bv; char buf[ STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" ) + 1 ]; char *ptr; - int i; + ber_len_t i; assert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) != 0 ); assert( !BER_BVISEMPTY( val ) ); @@ -4186,7 +4185,7 @@ csnNormalize21( gt = *val; ptr = ber_bvchr( >, '#' ); - if ( ptr == NULL || ptr - gt.bv_val == gt.bv_len ) { + if ( ptr == NULL || ptr == >.bv_val[gt.bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4203,7 +4202,7 @@ csnNormalize21( cnt.bv_len = val->bv_len - ( cnt.bv_val - val->bv_val ); ptr = ber_bvchr( &cnt, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4223,7 +4222,7 @@ csnNormalize21( sid.bv_len = val->bv_len - ( sid.bv_val - val->bv_val ); ptr = ber_bvchr( &sid, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4261,7 +4260,7 @@ csnNormalize21( } *ptr = '\0'; - assert( ptr - bv.bv_val == bv.bv_len ); + assert( ptr == &bv.bv_val[bv.bv_len] ); if ( csnValidate( syntax, &bv ) != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; @@ -4286,7 +4285,7 @@ csnNormalize23( struct berval bv; char buf[ STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" ) + 1 ]; char *ptr; - int i; + ber_len_t i; assert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) != 0 ); assert( !BER_BVISEMPTY( val ) ); @@ -4294,7 +4293,7 @@ csnNormalize23( gt = *val; ptr = ber_bvchr( >, '#' ); - if ( ptr == NULL || ptr - gt.bv_val == gt.bv_len ) { + if ( ptr == NULL || ptr == >.bv_val[gt.bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4307,7 +4306,7 @@ csnNormalize23( cnt.bv_len = val->bv_len - ( cnt.bv_val - val->bv_val ); ptr = ber_bvchr( &cnt, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4320,7 +4319,7 @@ csnNormalize23( sid.bv_len = val->bv_len - ( sid.bv_val - val->bv_val ); ptr = ber_bvchr( &sid, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4353,7 +4352,7 @@ csnNormalize23( } *ptr = '\0'; - assert( ptr - bv.bv_val == bv.bv_len ); + assert( ptr == &bv.bv_val[bv.bv_len] ); if ( csnValidate( syntax, &bv ) != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -4375,7 +4374,7 @@ csnNormalize( { struct berval cnt, sid, mod; char *ptr; - int i; + ber_len_t i; assert( val != NULL ); assert( normalized != NULL ); @@ -4403,7 +4402,7 @@ csnNormalize( } ptr = ber_bvchr( val, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4415,7 +4414,7 @@ csnNormalize( cnt.bv_len = val->bv_len - ( cnt.bv_val - val->bv_val ); ptr = ber_bvchr( &cnt, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } @@ -4427,7 +4426,7 @@ csnNormalize( sid.bv_len = val->bv_len - ( sid.bv_val - val->bv_val ); ptr = ber_bvchr( &sid, '#' ); - if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) { + if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 25b8805381..cf434106ae 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -180,7 +180,7 @@ do_search( if ( StatslogTest( LDAP_DEBUG_STATS ) ) { char abuf[BUFSIZ/2], *ptr = abuf; - int len = 0, alen; + unsigned len = 0, alen; sprintf(abuf, "scope=%d deref=%d", op->ors_scope, op->ors_deref); Statslog( LDAP_DEBUG_STATS, diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index 1a5d6584ba..0bbd91f406 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -396,7 +396,7 @@ static int pblock_set_default( Slapi_PBlock *pb, int param, void *value ) { slapi_pblock_class_t pbClass; - size_t i; + int i; pbClass = pblock_get_param_class( param ); if ( pbClass == PBLOCK_CLASS_INVALID ) { diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 8c9910b162..06768345c3 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -52,7 +52,7 @@ struct slapi_condvar { static int checkBVString(const struct berval *bv) { - int i; + ber_len_t i; for ( i = 0; i < bv->bv_len; i++ ) { if ( bv->bv_val[i] == '\0' ) @@ -3231,7 +3231,7 @@ LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared ) rc = snprintf( url, size, "ldap%s://%s/", ( secure ? "s" : "" ), ldaphost ); } - if ( rc > 0 && rc < size ) { + if ( rc > 0 && (size_t) rc < size ) { rc = ldap_initialize( &ld, url ); } else { ld = NULL; diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 516eb4a710..9df56882da 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -407,7 +407,7 @@ ldap_sync_search( abs(si->si_type), rhint ); } - if ( (rc = ber_flatten2( ber, &c[0].ldctl_value, 0 ) ) == LBER_ERROR ) { + if ( (rc = ber_flatten2( ber, &c[0].ldctl_value, 0 ) ) == -1 ) { ber_free_buf( ber ); return rc; } @@ -2733,7 +2733,8 @@ syncrepl_updateCookie( Modifications mod; struct berval first = BER_BVNULL; - int rc, i, j, len; + int rc, i, j; + ber_len_t len; slap_callback cb = { NULL }; SlapReply rs_modify = {REP_RESULT}; @@ -3056,7 +3057,8 @@ dn_callback( new = attr_find( dni->new_entry->e_attrs, slap_schema.si_ad_entryCSN ); if ( new && old ) { - int rc, len = old->a_vals[0].bv_len; + int rc; + ber_len_t len = old->a_vals[0].bv_len; if ( len > new->a_vals[0].bv_len ) len = new->a_vals[0].bv_len; rc = memcmp( old->a_vals[0].bv_val, diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 1f9d59cb85..ad7be0f466 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -267,12 +267,12 @@ ordered_value_renumber( Attribute *a ) { char *ptr, ibuf[64]; /* many digits */ struct berval ibv, tmp, vtmp; - int i; + unsigned i; ibv.bv_val = ibuf; for (i=0; ia_numvals; i++) { - ibv.bv_len = sprintf(ibv.bv_val, "{%d}", i); + ibv.bv_len = sprintf(ibv.bv_val, "{%u}", i); vtmp = a->a_vals[i]; if ( vtmp.bv_val[0] == '{' ) { ptr = ber_bvchr(&vtmp, '}'); @@ -750,7 +750,7 @@ ordered_value_add( k = strtol( vals[i].bv_val + 1, &next, 0 ); if ( next == vals[i].bv_val + 1 || next[ 0 ] != '}' || - next - vals[i].bv_val > vals[i].bv_len ) + (ber_len_t) (next - vals[i].bv_val) > vals[i].bv_len ) { ch_free( nnew ); ch_free( new ); -- 2.39.5