#ifdef NEW_LOGGING
        LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY,
-               "access_allowed: conn %d %s access to \"%s\" \"%s\" requested\n",
+               "access_allowed: conn %lu %s access to \"%s\" \"%s\" requested\n",
                conn ? conn->c_connid : -1, access2str( access ), e->e_dn, attr ));
 #else
        Debug( LDAP_DEBUG_ACL,
        if ( be != NULL && be_isroot( be, &op->o_ndn ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
-                      "access_allowed: conn %d root access granted\n",
+                      "access_allowed: conn %lu root access granted\n",
                       conn->c_connid));
 #else
                Debug( LDAP_DEBUG_ACL,
        {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                      "access_allowed: conn %d NoUserMod Operational attribute: %s access granted\n",
+                      "access_allowed: conn %lu NoUserMod Operational attribute: %s access granted\n",
                       conn->c_connid, attr ));
 #else
                Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:"
        if( be != NULL && be->be_acl == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                      "access_allowed: conn %d backend default %s access %s to \"%s\"\n",
+                      "access_allowed: conn %lu backend default %s access %s to \"%s\"\n",
                       conn->c_connid, access2str( access ),
                       be->be_dfltaccess >= access ? "granted" : "denied", op->o_dn.bv_val ));
 #else
        } else if ( be == NULL && global_acl == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                      "access_allowed: conn %d global default %s access %s to \"%s\"\n",
+                      "access_allowed: conn %lu global default %s access %s to \"%s\"\n",
                       conn->c_connid, access2str( access ),
                       global_default_access >= access ? "granted" : "denied", op->o_dn.bv_val ));
 #else
                for (i = 0; i < MAXREMATCHES && matches[i].rm_so > 0; i++) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                           "access_allowed: conn %d match[%d]:  %d %d ",
+                           "access_allowed: conn %lu match[%d]:  %d %d ",
                            conn->c_connid, i,
                                (int)matches[i].rm_so, (int)matches[i].rm_eo ));
 #else
        if ( ACL_IS_INVALID( mask ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                   "access_allowed: conn %d     \"%s\" (%s) invalid!\n",
+                   "access_allowed: conn %lu    \"%s\" (%s) invalid!\n",
                    conn->c_connid, e->e_dn, attr ));
 #else
                Debug( LDAP_DEBUG_ACL,
        } else if ( control == ACL_BREAK ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                      "access_allowed: conn %d  no more rules\n", conn->c_connid ));
+                      "access_allowed: conn %lu         no more rules\n", 
+                      conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ACL,
                        "=> access_allowed: no more rules\n", 0, 0, 0);
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY,
-               "access_allowed: conn %d  %s access %s by %s\n",
+               "access_allowed: conn %lu  %s access %s by %s\n",
                conn->c_connid,
                access2str( access ),
                ACL_GRANT( mask, access ) ? "granted" : "denied",
        AccessControlState *state )
 {
        int             i, odnlen, patlen;
-       int             vd_recorded = 0;
        Access  *b;
 #ifdef LDAP_DEBUG
        char accessmaskbuf[ACCESSMASK_MAXLEN];
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY,
-                  "acl_mask: conn %d  access to entry \"%s\", attr \"%s\" requested\n",
+                  "acl_mask: conn %lu  access to entry \"%s\", attr \"%s\" requested\n",
                   conn->c_connid, e->e_dn, attr ));
 
        LDAP_LOG(( "acl", LDAP_LEVEL_ARGS,
                if ( b->a_dn_pat.bv_len != 0 ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_dn_pat: %s\n",
+                                  "acl_mask: conn %lu  check a_dn_pat: %s\n",
                                   conn->c_connid, b->a_dn_pat.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "<= check a_dn_pat: %s\n",
                if ( b->a_sockurl_pat.bv_len ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_sockurl_pat: %s\n",
+                                  "acl_mask: conn %lu  check a_sockurl_pat: %s\n",
                                   conn->c_connid, b->a_sockurl_pat.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "<= check a_sockurl_pat: %s\n",
                if ( b->a_domain_pat.bv_len ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_domain_pat: %s\n",
+                                  "acl_mask: conn %lu  check a_domain_pat: %s\n",
                                   conn->c_connid, b->a_domain_pat.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "<= check a_domain_pat: %s\n",
                if ( b->a_peername_pat.bv_len ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_perrname_path: %s\n",
+                                  "acl_mask: conn %lu  check a_perrname_path: %s\n",
                                   conn->c_connid, b->a_peername_pat.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "<= check a_peername_path: %s\n",
                if ( b->a_sockname_pat.bv_len ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_sockname_path: %s\n",
+                                  "acl_mask: conn %lu  check a_sockname_path: %s\n",
                                   conn->c_connid, b->a_sockname_pat.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "<= check a_sockname_path: %s\n",
 
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_dn_pat: %s\n",
+                                  "acl_mask: conn %lu  check a_dn_pat: %s\n",
                                   conn->c_connid, attr ));
 #else
                        Debug( LDAP_DEBUG_ACL, "<= check a_dn_at: %s\n",
                if ( b->a_authz.sai_ssf ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_authz.sai_ssf: ACL %u > OP %u\n",
+                                  "acl_mask: conn %lu  check a_authz.sai_ssf: ACL %u > OP %u\n",
                                   conn->c_connid, b->a_authz.sai_ssf, op->o_ssf ));
 #else
                        Debug( LDAP_DEBUG_ACL, "<= check a_authz.sai_ssf: ACL %u > OP %u\n",
                if ( b->a_authz.sai_transport_ssf ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_authz.sai_transport_ssf: ACL %u > OP %u\n",
+                                  "acl_mask: conn %lu  check a_authz.sai_transport_ssf: ACL %u > OP %u\n",
                                   conn->c_connid, b->a_authz.sai_transport_ssf, op->o_transport_ssf ));
 #else
                        Debug( LDAP_DEBUG_ACL,
                if ( b->a_authz.sai_tls_ssf ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d  check a_authz.sai_tls_ssf: ACL %u > OP %u\n",
+                                  "acl_mask: conn %lu  check a_authz.sai_tls_ssf: ACL %u > OP %u\n",
                                   conn->c_connid, b->a_authz.sai_tls_ssf, op->o_tls_ssf ));
 #else
                        Debug( LDAP_DEBUG_ACL,
                if ( b->a_authz.sai_sasl_ssf ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                                  "acl_mask: conn %d check a_authz.sai_sasl_ssf: ACL %u > OP %u\n",
+                                  "acl_mask: conn %lu check a_authz.sai_sasl_ssf: ACL %u > OP %u\n",
                                   conn->c_connid, b->a_authz.sai_sasl_ssf, op->o_sasl_ssf ));
 #else
                        Debug( LDAP_DEBUG_ACL,
 
 #ifdef NEW_LOGGING
                LDAP_LOG(( "acl", LDAP_LEVEL_RESULTS,
-                          "acl_mask: conn %d  [%d] applying %s (%s)\n",
+                          "acl_mask: conn %lu  [%d] applying %s (%s)\n",
                           conn->c_connid, i, accessmask2str( modmask, accessmaskbuf),
                           b->a_type == ACL_CONTINUE ? "continue" : b->a_type == ACL_BREAK
                           ? "break" : "stop" ));
 
 #ifdef NEW_LOGGING
                LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
-                          "acl_mask: conn %d  [%d] mask: %s\n",
+                          "acl_mask: conn %lu  [%d] mask: %s\n",
                           conn->c_connid, i, accessmask2str( *mask, accessmaskbuf) ));
 #else
                Debug( LDAP_DEBUG_ACL,
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "acl", LDAP_LEVEL_RESULTS,
-                  "acl_mask: conn %d  no more <who> clauses, returning %d (stop)\n",
+                  "acl_mask: conn %lu  no more <who> clauses, returning %d (stop)\n",
                   conn->c_connid, accessmask2str( *mask, accessmaskbuf) ));
 #else
        Debug( LDAP_DEBUG_ACL,
        if ( be_isroot( be, &op->o_ndn ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
-                          "acl_check_modlist: conn %d  access granted to root user\n",
+                          "acl_check_modlist: conn %lu  access granted to root user\n",
                           conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ACL,
        if( be != NULL && be->be_acl == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
-                          "acl_check_modlist: conn %d  backend default %s access %s to \"%s\"\n",
+                          "acl_check_modlist: conn %lu  backend default %s access %s to \"%s\"\n",
                           conn->c_connid, access2str( ACL_WRITE ),
                           be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", op->o_dn.bv_val ));
 #else
        } else if ( be == NULL && global_acl == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
-                          "acl_check_modlist: conn %d  global default %s access %s to \"%s\"\n",
+                          "acl_check_modlist: conn %lu  global default %s access %s to \"%s\"\n",
                           conn->c_connid, access2str( ACL_WRITE ),
                           global_default_access >= ACL_WRITE ? "granted" : "denied", op->o_dn ));
 #else
                if ( is_at_no_user_mod( mlist->sml_desc->ad_type ) ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
-                                  "acl_check_modlist: conn %d  no-user-mod %s: modify access granted\n",
+                                  "acl_check_modlist: conn %lu  no-user-mod %s: modify access granted\n",
                                   conn->c_connid, mlist->sml_desc->ad_cname.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:"
        return( 1 );
 }
 
+#if 0 /* not used any more */
 static char *
 aci_bvstrdup( struct berval *bv )
 {
        }
        return(s);
 }
+#endif
 
 static int
 aci_get_part(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
-                  "string_expand:  pattern = %.*s\n", pat->bv_len, pat->bv_val ));
+                  "string_expand:  pattern = %.*s\n", (int)pat->bv_len, pat->bv_val ));
        LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
                   "string_expand:  expanded = %s\n", bv->bv_val ));
 #else
-       Debug( LDAP_DEBUG_TRACE, "=> string_expand: pattern:  %.*s\n", pat->bv_len, pat->bv_val, 0 );
+       Debug( LDAP_DEBUG_TRACE, "=> string_expand: pattern:  %.*s\n", (int)pat->bv_len, pat->bv_val, 0 );
        Debug( LDAP_DEBUG_TRACE, "=> string_expand: expanded: %s\n", bv->bv_val, 0, 0 );
 #endif
 }
 
        fprintf( wfp, "deref: %d\n", deref );
        fprintf( wfp, "sizelimit: %d\n", size );
        fprintf( wfp, "timelimit: %d\n", time );
-       fprintf( wfp, "filter: %s\n", filterstr );
+       fprintf( wfp, "filter: %s\n", filterstr->bv_val );
        fprintf( wfp, "attrsonly: %d\n", attrsonly ? 1 : 0 );
        fprintf( wfp, "attrs:%s", attrs == NULL ? " all" : "" );
        for ( an = attrs; an && an->an_name.bv_val; an++ ) {
 
 
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_RESULTS,
-                          "connection_get: get for %d got connid %ld\n",s, c->c_connid ));
+                          "connection_get: get for %d got connid %lu\n", s, c->c_connid ));
 #else
                Debug( LDAP_DEBUG_TRACE,
-                       "connection_get(%d): got connid=%ld\n",
+                       "connection_get(%d): got connid=%lu\n",
                        s, c->c_connid, 0 );
 #endif
 
        {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
-                          "connection_init: conn %d  set nonblocking failed\n",
+                          "connection_init: conn %lu  set nonblocking failed\n",
                           c->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY,
                slapd_remove( sd, 0 );
 
                Statslog( LDAP_DEBUG_STATS,
-                   "conn=%ld fd=%d closed\n",
+                   "conn=%lu fd=%d closed\n",
                        c->c_connid, sd, 0, 0, 0 );
        }
 
                ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_GET_FD, &sd );
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
-                          "connection_closing: conn %d readying socket %d for close.\n",
+                          "connection_closing: conn %lu readying socket %d for close.\n",
                           c->c_connid, sd ));
 #else
                Debug( LDAP_DEBUG_TRACE,
-                       "connection_closing: readying conn=%ld sd=%d for close\n",
+                       "connection_closing: readying conn=%lu sd=%d for close\n",
                        c->c_connid, sd, 0 );
 #endif
                /* update state to closing */
        if( !LDAP_STAILQ_EMPTY(&c->c_ops) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
-                          "connection_close: conn %d  deferring sd %d\n",
+                          "connection_close: conn %lu  deferring sd %d\n",
                           c->c_connid, sd ));
 #else
                Debug( LDAP_DEBUG_TRACE,
-                       "connection_close: deferring conn=%ld sd=%d\n",
+                       "connection_close: deferring conn=%lu sd=%d\n",
                        c->c_connid, sd, 0 );
 #endif
                return;
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "connection", LDAP_LEVEL_RESULTS,
-                  "connection_close: conn %d  sd %d\n",
+                  "connection_close: conn %lu  sd %d\n",
                   c->c_connid, sd ));
 #else
-       Debug( LDAP_DEBUG_TRACE, "connection_close: conn=%ld sd=%d\n",
+       Debug( LDAP_DEBUG_TRACE, "connection_close: conn=%lu sd=%d\n",
                c->c_connid, sd, 0 );
 #endif
        connection_destroy( c );
        if( conn->c_sasl_bind_in_progress && tag != LDAP_REQ_BIND ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                          "connection_operation: conn %d  SASL bind in progress (tag=%ld).\n",
+                          "connection_operation: conn %lu  SASL bind in progress (tag=%ld).\n",
                           conn->c_connid, (long)tag ));
 #else
                Debug( LDAP_DEBUG_ANY, "connection_operation: "
        default:
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
-                          "connection_operation: conn %d  unknown LDAP request 0x%lx\n",
+                          "connection_operation: conn %lu  unknown LDAP request 0x%lx\n",
                           conn->c_connid, tag ));
 #else
                Debug( LDAP_DEBUG_ANY, "unknown LDAP request 0x%lx\n",
        if( c->c_conn_state == SLAP_C_CLOSING ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
-                          "connection_read: conn %d connection closing, ignoring input\n",
+                          "connection_read: conn %lu connection closing, ignoring input\n",
                           c->c_connid));
 #else
                Debug( LDAP_DEBUG_TRACE,
-                       "connection_read(%d): closing, ignoring input for id=%ld\n",
+                       "connection_read(%d): closing, ignoring input for id=%lu\n",
                        s, c->c_connid, 0 );
 #endif
                connection_return( c );
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
-                  "connection_read: conn %d  checking for input.\n", c->c_connid ));
+                  "connection_read: conn %lu  checking for input.\n", c->c_connid ));
 #else
        Debug( LDAP_DEBUG_TRACE,
-               "connection_read(%d): checking for input on id=%ld\n",
+               "connection_read(%d): checking for input on id=%lu\n",
                s, c->c_connid, 0 );
 #endif
 
 
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                                  "connection_read: conn %d  TLS accept error, error %d\n",
+                                  "connection_read: conn %lu  TLS accept error, error %d\n",
                                   c->c_connid, rc ));
 #else
                        Debug( LDAP_DEBUG_TRACE,
                                "connection_read(%d): TLS accept error "
-                               "error=%d id=%ld, closing\n",
+                               "error=%d id=%lu, closing\n",
                                s, rc, c->c_connid );
 #endif
                        c->c_needs_tls_accept = 0;
                if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                                  "connection_read: conn %d SASL install error %d, closing\n",
+                                  "connection_read: conn %lu SASL install error %d, closing\n",
                                   c->c_connid, rc ));
 #else
                        Debug( LDAP_DEBUG_TRACE,
                                "connection_read(%d): SASL install error "
-                               "error=%d id=%ld, closing\n",
+                               "error=%d id=%lu, closing\n",
                                s, rc, c->c_connid );
 #endif
                        /* connections_mutex and c_mutex are locked */
        if( rc < 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                          "connection_read: conn %d  input error %d, closing.\n",
+                          "connection_read: conn %lu  input error %d, closing.\n",
                           c->c_connid, rc ));
 #else
                Debug( LDAP_DEBUG_TRACE,
-                       "connection_read(%d): input error=%d id=%ld, closing.\n",
+                       "connection_read(%d): input error=%d id=%lu, closing.\n",
                        s, rc, c->c_connid );
 #endif
                /* connections_mutex and c_mutex are locked */
            == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                          "connection_input: conn %d  ber_alloc failed.\n", conn->c_connid ));
+                          "connection_input: conn %lu  ber_alloc failed.\n", 
+                          conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
 #endif
                        inet_ntoa( peeraddr.sa_in_addr.sin_addr ),
                        (unsigned) ntohs( peeraddr.sa_in_addr.sin_port ) );
                Statslog( LDAP_DEBUG_STATS,
-                       "conn=%ld UDP request from %s (%s) accepted.\n",
+                       "conn=%lu UDP request from %s (%s) accepted.\n",
                        conn->c_connid, peername, conn->c_sock_name.bv_val, 0, 0 );
        }
 #endif
 
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                          "connection_input: conn %d  ber_get_next failed, errno %d (%s).\n",
+                          "connection_input: conn %lu  ber_get_next failed, errno %d (%s).\n",
                           conn->c_connid, err, sock_errstr(err) ));
 #else
                Debug( LDAP_DEBUG_TRACE,
                /* log, close and send error */
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                          "connection_input: conn %d  ber_get_int returns 0x%lx.\n",
+                          "connection_input: conn %lu  ber_get_int returns 0x%lx.\n",
                           conn->c_connid, tag ));
 #else
                Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%lx\n", tag, 0,
                /* log, close and send error */
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                          "connection_input: conn %d  ber_peek_tag returns 0x%lx.\n",
+                          "connection_input: conn %lu  ber_peek_tag returns 0x%lx.\n",
                           conn->c_connid, tag ));
 #else
                Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%lx\n", tag, 0,
                if (tag != LDAP_REQ_ABANDON && tag != LDAP_REQ_SEARCH) {
 #ifdef NEW_LOGGING
                    LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                              "connection_input: conn %d  invalid req for UDP 0x%lx.\n",
+                              "connection_input: conn %lu  invalid req for UDP 0x%lx.\n",
                               conn->c_connid, tag ));
 #else
                    Debug( LDAP_DEBUG_ANY, "invalid req for UDP 0x%lx\n", tag, 0,
        {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
-                          "connection_input: conn %d  deferring operation\n",
+                          "connection_input: conn %lu  deferring operation\n",
                           conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "deferring operation\n", 0, 0, 0 );
                if( rc ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
-                                  "connection_resched: conn %d  reaquiring locks.\n",
+                                  "connection_resched: conn %lu  reaquiring locks.\n",
                                   conn->c_connid ));
 #else
                        Debug( LDAP_DEBUG_TRACE,
-                               "connection_resched: reaquiring locks conn=%ld sd=%d\n",
+                               "connection_resched: reaquiring locks conn=%lu sd=%d\n",
                                conn->c_connid, sd, 0 );
 #endif
                        /*
                if( conn->c_conn_state != SLAP_C_CLOSING ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
-                                  "connection_resched: conn %d  closed by other thread.\n",
+                                  "connection_resched: conn %lu  closed by other thread.\n",
                                   conn->c_connid ));
 #else
                        Debug( LDAP_DEBUG_TRACE, "connection_resched: "
-                               "closed by other thread conn=%ld sd=%d\n",
+                               "closed by other thread conn=%lu sd=%d\n",
                                conn->c_connid, sd, 0 );
 #endif
                } else {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
-                                  "connection_resched: conn %d  attempting closing.\n",
+                                  "connection_resched: conn %lu  attempting closing.\n",
                                   conn->c_connid ));
 #else
                        Debug( LDAP_DEBUG_TRACE, "connection_resched: "
-                               "attempting closing conn=%ld sd=%d\n",
+                               "attempting closing conn=%lu sd=%d\n",
                                conn->c_connid, sd, 0 );
 #endif
                        connection_close( conn );
        if ( status != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
-                          "connection_op_activate: conn %d      thread pool submit failed.\n",
+                          "connection_op_activate: conn %lu     thread pool submit failed.\n",
                           conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY,
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
-                  "connection_write conn %d  waking output.\n",
+                  "connection_write conn %lu  waking output.\n",
                   c->c_connid ));
 #else
        Debug( LDAP_DEBUG_TRACE,
-               "connection_write(%d): waking output for id=%ld\n",
+               "connection_write(%d): waking output for id=%lu\n",
                s, c->c_connid, 0 );
 #endif
        ldap_pvt_thread_cond_signal( &c->c_write_cv );
 
        Operation *op,
        int sendres )
 {
-       int nctrls;
+       int nctrls = 0;
        ber_tag_t tag;
        ber_len_t len;
        char *opaque;
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
-               "get_ctrls: conn %d\n", conn->c_connid ));
+               "get_ctrls: conn %lu\n", conn->c_connid ));
 #else
        Debug( LDAP_DEBUG_TRACE, "=> get_ctrls\n", 0, 0, 0 );
 #endif
        }
 #endif
 
-       op->o_ctrls[nctrls=0] = NULL;
+       op->o_ctrls[nctrls] = NULL;
 
        /* step through each element */
        for( tag = ber_first_element( ber, &len, &opaque );
                if( tag == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                               "get_ctrls: conn %d get OID failed.\n",
+                               "get_ctrls: conn %lu get OID failed.\n",
                                conn->c_connid ));
 #else
                        Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: get oid failed.\n",
                        if( tag == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                                       "get_ctrls: conn %d get crit failed.\n",
+                                       "get_ctrls: conn %lu get crit failed.\n",
                                        conn->c_connid ));
 #else
                                Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: get crit failed.\n",
 
                        if( tag == LBER_ERROR ) {
 #ifdef NEW_LOGGING
-                               LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "get_ctrls: conn %d: "
+                               LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "get_ctrls: conn %lu: "
                                        "%s (%scritical): get value failed.\n",
                                        conn->c_connid,
                                        c->ldctl_oid ? c->ldctl_oid : "(NULL)",
                                        c->ldctl_iscritical ? "" : "non" ));
 #else
-                               Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: conn %d: "
+                               Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: conn %lu: "
                                        "%s (%scritical): get value failed.\n",
                                        conn->c_connid,
                                        c->ldctl_oid ? c->ldctl_oid : "(NULL)",
 
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                       "get_ctrls: conn %d oid=\"%s\" (%scritical)\n",
+                       "get_ctrls: conn %lu oid=\"%s\" (%scritical)\n",
                        conn->c_connid,
                        c->ldctl_oid ? c->ldctl_oid : "(NULL)",
                        c->ldctl_iscritical ? "" : "non" ));
 return_results:
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_RESULTS,
-               "get_ctrls: conn=%d     n=%d rc=%d err=%s\n",
+               "get_ctrls: conn=%lu    n=%d rc=%d err=%s\n",
                conn->c_connid, nctrls, rc, errmsg ? errmsg : "" ));
 #else
        Debug( LDAP_DEBUG_TRACE, "<= get_ctrls: n=%d rc=%d err=%s\n",
 
                                                *text = textbuf;
                                                snprintf( textbuf, textlen,
                                                        "modify/%s: %s: value #%i already exists",
-                                                       op, mod->sm_desc->ad_cname.bv_val );
+                                                       op, mod->sm_desc->ad_cname.bv_val, j );
                                                return LDAP_TYPE_OR_VALUE_EXISTS;
                                        }
                                }
                                        *text = textbuf;
                                        snprintf( textbuf, textlen,
                                                "modify/%s: %s: value #%i already exists",
-                                               op, mod->sm_desc->ad_cname.bv_val );
+                                               op, mod->sm_desc->ad_cname.bv_val, j );
                                        return LDAP_TYPE_OR_VALUE_EXISTS;
                                }
                        }
 {
        int             i, j, k, found;
        Attribute       *a;
-       char *desc = mod->sm_desc->ad_cname.bv_val;
-       MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
+       MatchingRule    *mr = mod->sm_desc->ad_type->sat_equality;
 
        /* delete the entire attribute */
        if ( mod->sm_bvalues == NULL ) {
 
 
        int as_result;
 } AccessControlState;
-#define ACL_STATE_INIT { ACL_STATE_NOT_RECORDED, NULL, 0UL, { 0 }, 0, NULL, 0 }
+#define ACL_STATE_INIT { ACL_STATE_NOT_RECORDED, NULL, 0UL, { { 0, 0 } }, 0, NULL, 0, 0 }
 
 /*
  * replog moddn param structure