From 3743579870464e52f9dfa5b423e5146d32a14dc8 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Mon, 8 Nov 2004 10:55:33 +0000 Subject: [PATCH] fix typo in rww; general cleanup --- servers/slapd/back-monitor/backend.c | 14 ++-- servers/slapd/back-monitor/conn.c | 20 +++--- servers/slapd/back-monitor/database.c | 13 ++-- servers/slapd/back-monitor/entry.c | 16 +++++ servers/slapd/back-monitor/init.c | 67 +++++++++---------- servers/slapd/back-monitor/listener.c | 17 ++--- servers/slapd/back-monitor/log.c | 36 +++++----- servers/slapd/back-monitor/operation.c | 11 +-- servers/slapd/back-monitor/overlay.c | 9 +-- .../slapd/back-monitor/proto-back-monitor.h | 1 + servers/slapd/back-monitor/rww.c | 29 ++++---- servers/slapd/back-monitor/sent.c | 19 +++--- servers/slapd/back-monitor/thread.c | 14 ++-- servers/slapd/back-monitor/time.c | 18 ++--- 14 files changed, 157 insertions(+), 127 deletions(-) diff --git a/servers/slapd/back-monitor/backend.c b/servers/slapd/back-monitor/backend.c index 48db0592ea..7bdb01736b 100644 --- a/servers/slapd/back-monitor/backend.c +++ b/servers/slapd/back-monitor/backend.c @@ -76,7 +76,7 @@ monitor_subsys_backend_init( int j; Entry *e; - bi = &backendInfo[i]; + bi = &backendInfo[ i ]; snprintf( buf, sizeof( buf ), "dn: cn=Backend %d,%s\n" @@ -125,7 +125,7 @@ monitor_subsys_backend_init( } for ( j = 0; j < nBackendDB; j++ ) { - BackendDB *be = &backendDB[j]; + BackendDB *be = &backendDB[ j ]; char buf[ SLAP_LDAPDN_MAXLEN ]; struct berval dn; @@ -142,13 +142,13 @@ monitor_subsys_backend_init( &dn, NULL ); } - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; - mp->mp_flags = ms->mss_flags - | MONITOR_F_SUB; + mp->mp_flags = ms->mss_flags | MONITOR_F_SUB; if ( monitor_cache_add( mi, e ) ) { Debug( LDAP_DEBUG_ANY, diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 0253d5a7c3..1667a6ae9f 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -89,10 +89,11 @@ monitor_subsys_conn_init( BER_BVSTR( &bv, "0" ); attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; @@ -141,10 +142,11 @@ monitor_subsys_conn_init( BER_BVSTR( &bv, "0" ); attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; @@ -397,10 +399,12 @@ conn_create( attr_merge_one( e, mi->mi_ad_monitorConnectionPeerAddress, &c->c_peer_name, NULL ); - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; mp->mp_info = ms; - mp->mp_children = NULL; mp->mp_flags = MONITOR_F_SUB | MONITOR_F_VOLATILE; *ep = e; diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index b157181d07..c671e01268 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -155,7 +155,7 @@ monitor_subsys_database_init( BackendInfo *bi; Entry *e; - be = &backendDB[i]; + be = &backendDB[ i ]; bi = be->bd_info; @@ -274,10 +274,11 @@ monitor_subsys_database_init( /* we must find it! */ assert( j >= 0 ); - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags | MONITOR_F_SUB; @@ -373,7 +374,7 @@ monitor_subsys_database_modify( return LDAP_NO_SUCH_OBJECT; /* do not allow some changes on back-monitor (needs work)... */ - be = &backendDB[n]; + be = &backendDB[ n ]; if ( SLAP_MONITOR( be ) ) return LDAP_UNWILLING_TO_PERFORM; @@ -549,7 +550,7 @@ monitor_subsys_database_modify( goto done; } - if ( !bvmatch( &a->a_vals[0], tf ) ) { + if ( !bvmatch( &a->a_vals[ 0 ], tf ) ) { attr_delete( &e->e_attrs, mi->mi_ad_readOnly ); rc = attr_merge_one( e, mi->mi_ad_readOnly, tf, NULL ); } diff --git a/servers/slapd/back-monitor/entry.c b/servers/slapd/back-monitor/entry.c index 08a758f882..869f37c79c 100644 --- a/servers/slapd/back-monitor/entry.c +++ b/servers/slapd/back-monitor/entry.c @@ -110,3 +110,19 @@ monitor_entry_test_flags( return( ( mp->mp_flags & cond ) || ( mp->mp_info->mss_flags & cond ) ); } +struct monitorentrypriv * +monitor_entrypriv_create( void ) +{ + struct monitorentrypriv *mp; + + mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + + mp->mp_next = NULL; + mp->mp_children = NULL; + mp->mp_info = NULL; + mp->mp_flags = MONITOR_F_NONE; + mp->mp_update = NULL; + mp->mp_private = NULL; + + return mp; +} diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 456c6894d5..a745898682 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -548,23 +548,23 @@ monitor_back_db_init( #ifdef INTEGRATE_CORE_SCHEMA /* prepare for schema integration */ - for ( k = 0; mat[k].name != NULL; k++ ); + for ( k = 0; mat[ k ].name != NULL; k++ ); #endif /* INTEGRATE_CORE_SCHEMA */ - for ( i = 0; mat_core[i].name != NULL; i++ ) { + for ( i = 0; mat_core[ i ].name != NULL; i++ ) { AttributeDescription **ad; const char *text; - ad = ((AttributeDescription **)&(((char *)mi)[mat_core[i].offset])); - ad[0] = NULL; + ad = ((AttributeDescription **)&(((char *)mi)[ mat_core[ i ].offset ])); + ad[ 0 ] = NULL; - switch (slap_str2ad( mat_core[i].name, ad, &text ) ) { + switch (slap_str2ad( mat_core[ i ].name, ad, &text ) ) { case LDAP_SUCCESS: break; #ifdef INTEGRATE_CORE_SCHEMA case LDAP_UNDEFINED_TYPE: - mat[k] = mat_core[i]; + mat[ k ] = mat_core[ i ]; k++; break; #endif /* INTEGRATE_CORE_SCHEMA */ @@ -572,31 +572,31 @@ monitor_back_db_init( default: Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: %s: %s\n", - mat_core[i].name, text, 0 ); + mat_core[ i ].name, text, 0 ); return( -1 ); } } /* schema integration */ - for ( i = 0; mat[i].name; i++ ) { + for ( i = 0; mat[ i ].name; i++ ) { LDAPAttributeType *at; int code; const char *err; AttributeDescription **ad; - at = ldap_str2attributetype( mat[i].schema, &code, + at = ldap_str2attributetype( mat[ i ].schema, &code, &err, LDAP_SCHEMA_ALLOW_ALL ); if ( !at ) { Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: " "in AttributeType \"%s\" %s before %s\n", - mat[i].name, ldap_scherr2str(code), err ); + mat[ i ].name, ldap_scherr2str(code), err ); return -1; } if ( at->at_oid == NULL ) { Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: " "null OID for attributeType \"%s\"\n", - mat[i].name, 0, 0 ); + mat[ i ].name, 0, 0 ); return -1; } @@ -604,34 +604,34 @@ monitor_back_db_init( if ( code ) { Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: " "%s in attributeType \"%s\"\n", - scherr2str(code), mat[i].name, 0 ); + scherr2str(code), mat[ i ].name, 0 ); return -1; } ldap_memfree(at); - ad = ((AttributeDescription **)&(((char *)mi)[mat[i].offset])); - ad[0] = NULL; - if ( slap_str2ad( mat[i].name, ad, &text ) ) { + ad = ((AttributeDescription **)&(((char *)mi)[ mat[ i ].offset ])); + ad[ 0 ] = NULL; + if ( slap_str2ad( mat[ i ].name, ad, &text ) ) { Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: %s\n", text, 0, 0 ); return -1; } - (*ad)->ad_type->sat_flags |= mat[i].flags; + (*ad)->ad_type->sat_flags |= mat[ i ].flags; } - for ( i = 0; moc[i].name; i++ ) { + for ( i = 0; moc[ i ].name; i++ ) { LDAPObjectClass *oc; int code; const char *err; ObjectClass *Oc; - oc = ldap_str2objectclass(moc[i].schema, &code, &err, + oc = ldap_str2objectclass(moc[ i ].schema, &code, &err, LDAP_SCHEMA_ALLOW_ALL ); if ( !oc ) { Debug( LDAP_DEBUG_ANY, "unable to parse monitor objectclass \"%s\": " - "%s before %s\n" , moc[i].name, + "%s before %s\n" , moc[ i ].name, ldap_scherr2str(code), err ); return -1; } @@ -639,7 +639,7 @@ monitor_back_db_init( if ( oc->oc_oid == NULL ) { Debug( LDAP_DEBUG_ANY, "objectclass \"%s\" has no OID\n" , - moc[i].name, 0, 0 ); + moc[ i ].name, 0, 0 ); return -1; } @@ -647,23 +647,23 @@ monitor_back_db_init( if ( code ) { Debug( LDAP_DEBUG_ANY, "objectclass \"%s\": %s \"%s\"\n" , - moc[i].name, scherr2str(code), err ); + moc[ i ].name, scherr2str(code), err ); return -1; } ldap_memfree(oc); - Oc = oc_find( moc[i].name ); + Oc = oc_find( moc[ i ].name ); if ( Oc == NULL ) { Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: " "unable to find objectClass %s " - "(just added)\n", moc[i].name, 0, 0 ); + "(just added)\n", moc[ i ].name, 0, 0 ); return -1; } - Oc->soc_flags |= moc[i].flags; + Oc->soc_flags |= moc[ i ].flags; - ((ObjectClass **)&(((char *)mi)[moc[i].offset]))[0] = Oc; + ((ObjectClass **)&(((char *)mi)[ moc[ i ].offset ]))[ 0 ] = Oc; } return 0; @@ -786,13 +786,11 @@ monitor_back_db_open( } } - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - - mp->mp_info = NULL; - mp->mp_children = NULL; - mp->mp_next = NULL; - ep = &mp->mp_children; if ( monitor_cache_add( mi, e ) ) { @@ -864,11 +862,12 @@ monitor_back_db_open( return( -1 ); } - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; mp->mp_info = monitor_subsys[ i ]; - mp->mp_children = NULL; mp->mp_flags = monitor_subsys[ i ]->mss_flags; if ( monitor_cache_add( mi, e ) ) { diff --git a/servers/slapd/back-monitor/listener.c b/servers/slapd/back-monitor/listener.c index fff9e892c9..0462626320 100644 --- a/servers/slapd/back-monitor/listener.c +++ b/servers/slapd/back-monitor/listener.c @@ -68,7 +68,7 @@ monitor_subsys_listener_init( mp->mp_children = NULL; ep = &mp->mp_children; - for ( i = 0; l[i]; i++ ) { + for ( i = 0; l[ i ]; i++ ) { char buf[ BACKMONITOR_BUFSIZE ]; Entry *e; @@ -89,8 +89,8 @@ monitor_subsys_listener_init( mi->mi_oc_monitoredObject->soc_cname.bv_val, i, mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val, - l[i]->sl_name.bv_val, - l[i]->sl_url.bv_val, + l[ i ]->sl_name.bv_val, + l[ i ]->sl_url.bv_val, mi->mi_creatorsName.bv_val, mi->mi_creatorsName.bv_val, mi->mi_startTime.bv_val, @@ -106,7 +106,7 @@ monitor_subsys_listener_init( } #ifdef HAVE_TLS - if ( l[i]->sl_is_tls ) { + if ( l[ i ]->sl_is_tls ) { struct berval bv; bv.bv_val = "TLS"; @@ -117,7 +117,7 @@ monitor_subsys_listener_init( } #endif /* HAVE_TLS */ #ifdef LDAP_CONNECTIONLESS - if ( l[i]->sl_is_udp ) { + if ( l[ i ]->sl_is_udp ) { struct berval bv; BER_BVSTR( &bv, "UDP" ); @@ -126,10 +126,11 @@ monitor_subsys_listener_init( } #endif /* HAVE_TLS */ - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags | MONITOR_F_SUB; diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 74b9f6a5c4..23cf7faf16 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -274,10 +274,10 @@ check_constraints( Modification *mod, int *newlevel ) { int i; - for ( i = 0; mod->sm_values && mod->sm_values[i].bv_val != NULL; i++ ) { + for ( i = 0; mod->sm_values && !BER_BVISNULL( &mod->sm_values[ i ] ); i++ ) { int l; - l = loglevel2int( &mod->sm_values[i] ); + l = loglevel2int( &mod->sm_values[ i ] ); if ( !l ) { return LDAP_CONSTRAINT_VIOLATION; } @@ -287,13 +287,13 @@ check_constraints( Modification *mod, int *newlevel ) } assert( int_2_level[ l ].s.bv_len - == mod->sm_values[i].bv_len ); + == mod->sm_values[ i ].bv_len ); - AC_MEMCPY( mod->sm_values[i].bv_val, + AC_MEMCPY( mod->sm_values[ i ].bv_val, int_2_level[ l ].s.bv_val, int_2_level[ l ].s.bv_len ); - AC_MEMCPY( mod->sm_nvalues[i].bv_val, + AC_MEMCPY( mod->sm_nvalues[ i ].bv_val, int_2_level[ l ].n.bv_val, int_2_level[ l ].n.bv_len ); @@ -323,7 +323,7 @@ add_values( Entry *e, Modification *mod, int *newlevel ) return LDAP_INAPPROPRIATE_MATCHING; } - for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) { + for ( i = 0; !BER_BVISNULL( &mod->sm_values[ i ] ); i++ ) { int rc; int j; const char *text = NULL; @@ -331,16 +331,16 @@ add_values( Entry *e, Modification *mod, int *newlevel ) rc = asserted_value_validate_normalize( mod->sm_desc, mr, SLAP_MR_EQUALITY, - &mod->sm_values[i], &asserted, &text, NULL ); + &mod->sm_values[ i ], &asserted, &text, NULL ); if ( rc != LDAP_SUCCESS ) { return rc; } - for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) { + for ( j = 0; !BER_BVISNULL( &a->a_vals[ j ] ); j++ ) { int match; int rc = value_match( &match, mod->sm_desc, mr, - 0, &a->a_vals[j], &asserted, &text ); + 0, &a->a_vals[ j ], &asserted, &text ); if ( rc == LDAP_SUCCESS && match == 0 ) { free( asserted.bv_val ); @@ -401,7 +401,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) } /* find each value to delete */ - for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) { + for ( i = 0; !BER_BVISNULL( &mod->sm_values[ i ] ); i++ ) { int rc; const char *text = NULL; @@ -409,16 +409,16 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) rc = asserted_value_validate_normalize( mod->sm_desc, mr, SLAP_MR_EQUALITY, - &mod->sm_values[i], &asserted, &text, NULL ); + &mod->sm_values[ i ], &asserted, &text, NULL ); if( rc != LDAP_SUCCESS ) return rc; found = 0; - for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) { + for ( j = 0; !BER_BVISNULL( &a->a_vals[ j ] ); j++ ) { int match; int rc = value_match( &match, mod->sm_desc, mr, 0, - &a->a_vals[j], &asserted, &text ); + &a->a_vals[ j ], &asserted, &text ); if( rc == LDAP_SUCCESS && match != 0 ) { continue; @@ -428,11 +428,11 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) found = 1; /* delete it */ - free( a->a_vals[j].bv_val ); - for ( k = j + 1; a->a_vals[k].bv_val != NULL; k++ ) { - a->a_vals[k - 1] = a->a_vals[k]; + free( a->a_vals[ j ].bv_val ); + for ( k = j + 1; !BER_BVISNULL( &a->a_vals[ k ] ); k++ ) { + a->a_vals[ k - 1 ] = a->a_vals[ k ]; } - a->a_vals[k - 1].bv_val = NULL; + BER_BVZERO( &a->a_vals[ k - 1 ] ); break; } @@ -446,7 +446,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) } /* if no values remain, delete the entire attribute */ - if ( a->a_vals[0].bv_val == NULL ) { + if ( BER_BVISNULL( &a->a_vals[ 0 ] ) ) { /* should already be zero */ *newlevel = 0; diff --git a/servers/slapd/back-monitor/operation.c b/servers/slapd/back-monitor/operation.c index 090405646f..87cdfc6814 100644 --- a/servers/slapd/back-monitor/operation.c +++ b/servers/slapd/back-monitor/operation.c @@ -103,7 +103,7 @@ monitor_subsys_ops_init( ms->mss_dn.bv_val, mi->mi_oc_monitorOperation->soc_cname.bv_val, mi->mi_oc_monitorOperation->soc_cname.bv_val, - &monitor_op[ i ].rdn.bv_val[STRLENOF( "cn=" )], + &monitor_op[ i ].rdn.bv_val[ STRLENOF( "cn=" ) ], mi->mi_ad_monitorOpInitiated->ad_cname.bv_val, mi->mi_ad_monitorOpCompleted->ad_cname.bv_val, mi->mi_creatorsName.bv_val, @@ -123,12 +123,13 @@ monitor_subsys_ops_init( /* steal normalized RDN */ dnRdn( &e->e_nname, &rdn ); - ber_dupbv( &monitor_op[i].nrdn, &rdn ); + ber_dupbv( &monitor_op[ i ].nrdn, &rdn ); - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; diff --git a/servers/slapd/back-monitor/overlay.c b/servers/slapd/back-monitor/overlay.c index 7610a6f801..53980bfd57 100644 --- a/servers/slapd/back-monitor/overlay.c +++ b/servers/slapd/back-monitor/overlay.c @@ -114,7 +114,7 @@ monitor_subsys_overlay_init( &bv, NULL ); for ( j = 0; j < nBackendDB; j++ ) { - BackendDB *be = &backendDB[j]; + BackendDB *be = &backendDB[ j ]; char buf[ SLAP_LDAPDN_MAXLEN ]; struct berval dn; slap_overinst *on2; @@ -143,10 +143,11 @@ monitor_subsys_overlay_init( &dn, NULL ); } - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags | MONITOR_F_SUB; diff --git a/servers/slapd/back-monitor/proto-back-monitor.h b/servers/slapd/back-monitor/proto-back-monitor.h index 5c00800b8c..ee8d7d7c00 100644 --- a/servers/slapd/back-monitor/proto-back-monitor.h +++ b/servers/slapd/back-monitor/proto-back-monitor.h @@ -65,6 +65,7 @@ extern int monitor_entry_create LDAP_P(( Operation *op, struct berval *ndn, Entry *e_parent, Entry **ep )); extern int monitor_entry_modify LDAP_P(( Operation *op, Entry *e )); int monitor_entry_test_flags LDAP_P(( struct monitorentrypriv *mp, int cond )); +extern struct monitorentrypriv * monitor_entrypriv_create LDAP_P(( void )); /* * init diff --git a/servers/slapd/back-monitor/rww.c b/servers/slapd/back-monitor/rww.c index ada1c27825..d4cffb8b5b 100644 --- a/servers/slapd/back-monitor/rww.c +++ b/servers/slapd/back-monitor/rww.c @@ -87,11 +87,11 @@ monitor_subsys_rww_init( "modifiersName: %s\n" "createTimestamp: %s\n" "modifyTimestamp: %s\n", - monitor_rww[i].rdn.bv_val, + monitor_rww[ i ].rdn.bv_val, ms->mss_dn.bv_val, mi->mi_oc_monitorCounterObject->soc_cname.bv_val, mi->mi_oc_monitorCounterObject->soc_cname.bv_val, - &monitor_rww[i].rdn.bv_val[STRLENOF("cn")], + &monitor_rww[ i ].rdn.bv_val[ STRLENOF( "cn=" ) ], mi->mi_creatorsName.bv_val, mi->mi_creatorsName.bv_val, mi->mi_startTime.bv_val, @@ -108,15 +108,16 @@ monitor_subsys_rww_init( /* steal normalized RDN */ dnRdn( &e->e_nname, &nrdn ); - ber_dupbv( &monitor_rww[i].nrdn, &nrdn ); + ber_dupbv( &monitor_rww[ i ].nrdn, &nrdn ); BER_BVSTR( &bv, "0" ); attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; @@ -125,7 +126,7 @@ monitor_subsys_rww_init( Debug( LDAP_DEBUG_ANY, "monitor_subsys_rww_init: " "unable to add entry \"%s,%s\"\n", - monitor_rww[i].rdn.bv_val, + monitor_rww[ i ].rdn.bv_val, ms->mss_ndn.bv_val, 0 ); return( -1 ); } @@ -163,8 +164,8 @@ monitor_subsys_rww_update( dnRdn( &e->e_nname, &nrdn ); - for ( i = 0; !BER_BVISNULL( &monitor_rww[i].nrdn ); i++ ) { - if ( dn_match( &nrdn, &monitor_rww[i].nrdn ) ) { + for ( i = 0; !BER_BVISNULL( &monitor_rww[ i ].nrdn ); i++ ) { + if ( dn_match( &nrdn, &monitor_rww[ i ].nrdn ) ) { break; } } @@ -207,14 +208,14 @@ monitor_subsys_rww_update( a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter ); assert( a ); len = strlen( buf ); - if ( len > a->a_vals[0].bv_len ) { - a->a_vals[0].bv_val = ber_memrealloc( a->a_vals[0].bv_val, len + 1 ); - if ( a->a_vals[0].bv_val == NULL ) { - BER_BVZERO( &a->a_vals[0] ); + if ( len > a->a_vals[ 0 ].bv_len ) { + a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 ); + if ( BER_BVISNULL( &a->a_vals[ 0 ] ) ) { + BER_BVZERO( &a->a_vals[ 0 ] ); return( 0 ); } } - AC_MEMCPY( a->a_vals[0].bv_val, buf, len + 1 ); + AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 ); a->a_vals[ 0 ].bv_len = len; return( 0 ); diff --git a/servers/slapd/back-monitor/sent.c b/servers/slapd/back-monitor/sent.c index 6c8615c241..dfcffc8e0f 100644 --- a/servers/slapd/back-monitor/sent.c +++ b/servers/slapd/back-monitor/sent.c @@ -89,11 +89,11 @@ monitor_subsys_sent_init( "modifiersName: %s\n" "createTimestamp: %s\n" "modifyTimestamp: %s\n", - monitor_sent[i].rdn.bv_val, + monitor_sent[ i ].rdn.bv_val, ms->mss_dn.bv_val, mi->mi_oc_monitorCounterObject->soc_cname.bv_val, mi->mi_oc_monitorCounterObject->soc_cname.bv_val, - &monitor_sent[i].rdn.bv_val[STRLENOF( "cn=" )], + &monitor_sent[ i ].rdn.bv_val[ STRLENOF( "cn=" ) ], mi->mi_creatorsName.bv_val, mi->mi_creatorsName.bv_val, mi->mi_startTime.bv_val, @@ -104,22 +104,23 @@ monitor_subsys_sent_init( Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to create entry \"%s,%s\"\n", - monitor_sent[i].rdn.bv_val, + monitor_sent[ i ].rdn.bv_val, ms->mss_ndn.bv_val, 0 ); return( -1 ); } /* steal normalized RDN */ dnRdn( &e->e_nname, &nrdn ); - ber_dupbv( &monitor_sent[i].nrdn, &nrdn ); + ber_dupbv( &monitor_sent[ i ].nrdn, &nrdn ); BER_BVSTR( &bv, "0" ); attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; @@ -128,7 +129,7 @@ monitor_subsys_sent_init( Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to add entry \"%s,%s\"\n", - monitor_sent[i].rdn.bv_val, + monitor_sent[ i ].rdn.bv_val, ms->mss_ndn.bv_val, 0 ); return( -1 ); } @@ -162,7 +163,7 @@ monitor_subsys_sent_update( dnRdn( &e->e_nname, &nrdn ); for ( i = 0; i < MONITOR_SENT_LAST; i++ ) { - if ( dn_match( &nrdn, &monitor_sent[i].nrdn ) ) { + if ( dn_match( &nrdn, &monitor_sent[ i ].nrdn ) ) { break; } } diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index 12a674b308..de7819dd41 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -87,10 +87,11 @@ monitor_subsys_thread_init( return( -1 ); } - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; @@ -137,10 +138,11 @@ monitor_subsys_thread_init( return( -1 ); } - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; diff --git a/servers/slapd/back-monitor/time.c b/servers/slapd/back-monitor/time.c index ca5b00de49..dd8e90dd5f 100644 --- a/servers/slapd/back-monitor/time.c +++ b/servers/slapd/back-monitor/time.c @@ -89,10 +89,11 @@ monitor_subsys_time_init( return( -1 ); } - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; @@ -140,10 +141,11 @@ monitor_subsys_time_init( return( -1 ); } - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + mp = monitor_entrypriv_create(); + if ( mp == NULL ) { + return -1; + } e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; mp->mp_info = ms; mp->mp_flags = ms->mss_flags \ | MONITOR_F_SUB | MONITOR_F_PERSISTENT; @@ -222,8 +224,8 @@ monitor_subsys_time_update( return( -1 ); } - assert( len == a->a_vals[0].bv_len ); - AC_MEMCPY( a->a_vals[0].bv_val, tmbuf, len ); + assert( len == a->a_vals[ 0 ].bv_len ); + AC_MEMCPY( a->a_vals[ 0 ].bv_val, tmbuf, len ); } return( 0 ); -- 2.39.5