]> git.sur5r.net Git - openldap/commitdiff
fix typo in rww; general cleanup
authorPierangelo Masarati <ando@openldap.org>
Mon, 8 Nov 2004 10:55:33 +0000 (10:55 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 8 Nov 2004 10:55:33 +0000 (10:55 +0000)
14 files changed:
servers/slapd/back-monitor/backend.c
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/database.c
servers/slapd/back-monitor/entry.c
servers/slapd/back-monitor/init.c
servers/slapd/back-monitor/listener.c
servers/slapd/back-monitor/log.c
servers/slapd/back-monitor/operation.c
servers/slapd/back-monitor/overlay.c
servers/slapd/back-monitor/proto-back-monitor.h
servers/slapd/back-monitor/rww.c
servers/slapd/back-monitor/sent.c
servers/slapd/back-monitor/thread.c
servers/slapd/back-monitor/time.c

index 48db0592ea5a944ef0cb70d3f89d1566d588e186..7bdb01736b21148dd1f69cd717b3eb1d4ea4f06b 100644 (file)
@@ -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,
index 0253d5a7c37cdd945c556330946955ee1589fb9e..1667a6ae9f8ea5424329c5da0e64544101e6a6d5 100644 (file)
@@ -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;
index b157181d0751f1e77855de55c8713d67cc3b791b..c671e01268fd8ef3944f646b59107126bd11dd10 100644 (file)
@@ -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 );
        }
index 08a758f8829058e8aec0c0b069afa916f07119d8..869f37c79cef582b46ebf353b298d1687e286d95 100644 (file)
@@ -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;
+}
index 456c6894d5abd04ddca82a258e4d40606d0d280c..a74589868212e776969ea72fb00b2edbde762299 100644 (file)
@@ -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 ) ) {
index fff9e892c98e9542943678535e23b8c96ad94762..0462626320e11e23f068dcf2bff6f9327917cd30 100644 (file)
@@ -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;
index 74b9f6a5c41df7651703b2b2e5280be1ce2ea538..23cf7faf162d404c0d0fa66b073c4ebb8b131315 100644 (file)
@@ -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;
                
index 090405646fb11ae59751cfce374751c929c223f6..87cdfc6814944697b9375075d5a16b27aff852b4 100644 (file)
@@ -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;
index 7610a6f8018fee80c49fe8fb085678c6023b92b1..53980bfd5770924d29d22597a8d53ae56588625d 100644 (file)
@@ -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;
index 5c00800b8cbca6141cf76a4da9017a8f6a842baf..ee8d7d7c00b1a6aef2adf0503ea91fbebce7a590 100644 (file)
@@ -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
index ada1c27825870abf0c8e6b73302a23c59e6bef1d..d4cffb8b5b0c468b5a732a8c554e7661725f7f78 100644 (file)
@@ -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 );
index 6c8615c2419385ed8e50be713e829c81270fb6b3..dfcffc8e0f3a877261e727300df34424e5fe4c36 100644 (file)
@@ -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;
                }
        }
index 12a674b3086431a3968bf5f316292a230d49b545..de7819dd415fe78672c75e7e5a9732a85257b2d9 100644 (file)
@@ -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;
index ca5b00de4988432bcdf39ff08ca0144c0b019992..dd8e90dd5f384b4064664bd39ca469d9192a4ebf 100644 (file)
@@ -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 );