]> git.sur5r.net Git - openldap/commitdiff
cleanup
authorPierangelo Masarati <ando@openldap.org>
Thu, 18 May 2006 00:37:56 +0000 (00:37 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 18 May 2006 00:37:56 +0000 (00:37 +0000)
libraries/libldap/abandon.c
libraries/libldap/request.c
libraries/libldap/result.c

index bc9aae03e03cfe691acb8b7ef5306ac723f7e7da..551940d1b1655dbbe13d3584db06cf2be8dd05ae 100644 (file)
@@ -110,11 +110,11 @@ do_abandon(
        ber_int_t origid,
        ber_int_t msgid,
        LDAPControl **sctrls,
-       LDAPControl **cctrls)
+       LDAPControl **cctrls )
 {
        BerElement      *ber;
        int             i, err, sendabandon;
-       ber_int_t *old_abandon;
+       ber_int_t       *old_abandon;
        Sockbuf         *sb;
        LDAPRequest     *lr;
 
@@ -191,23 +191,24 @@ do_abandon(
                        i = ++(ld)->ld_msgid;
 #ifdef LDAP_CONNECTIONLESS
                        if ( LDAP_IS_UDP(ld) ) {
-                           err = ber_write( ber, ld->ld_options.ldo_peer,
-                               sizeof(struct sockaddr), 0);
+                               err = ber_write( ber, ld->ld_options.ldo_peer,
+                                       sizeof(struct sockaddr), 0);
                        }
                        if ( LDAP_IS_UDP(ld) && ld->ld_options.ldo_version ==
-                               LDAP_VERSION2) {
-                           char *dn = ld->ld_options.ldo_cldapdn;
-                           if (!dn) dn = "";
-                           err = ber_printf( ber, "{isti",  /* '}' */
-                               i, dn,
-                               LDAP_REQ_ABANDON, msgid );
+                               LDAP_VERSION2 )
+                       {
+                               char *dn = ld->ld_options.ldo_cldapdn;
+                               if (!dn) dn = "";
+                               err = ber_printf( ber, "{isti",  /* '}' */
+                                       i, dn,
+                                       LDAP_REQ_ABANDON, msgid );
                        } else
 #endif
                        {
-                           /* create a message to send */
-                           err = ber_printf( ber, "{iti",  /* '}' */
-                               i,
-                               LDAP_REQ_ABANDON, msgid );
+                               /* create a message to send */
+                               err = ber_printf( ber, "{iti",  /* '}' */
+                                       i,
+                                       LDAP_REQ_ABANDON, msgid );
                        }
 
                        if( err == -1 ) {
index 48e2b0e2d820883374b7235932c8872cffc3a465..14a2515e9e3e6c9a3bb9ba9669ef1ed32aff9852 100644 (file)
@@ -70,7 +70,8 @@ ldap_alloc_ber_with_options( LDAP *ld )
 {
        BerElement      *ber;
 
-    if (( ber = ber_alloc_t( ld->ld_lberoptions )) == NULL ) {
+       ber = ber_alloc_t( ld->ld_lberoptions );
+       if ( ber == NULL ) {
                ld->ld_errno = LDAP_NO_MEMORY;
        }
 
@@ -236,7 +237,7 @@ ldap_send_server_request(
        }
        if ( rc ) return rc;
 
-       lr = (LDAPRequest *)LDAP_CALLOC( 1, sizeof( LDAPRequest ));
+       lr = (LDAPRequest *)LDAP_CALLOC( 1, sizeof( LDAPRequest ) );
        if ( lr == NULL ) {
                ld->ld_errno = LDAP_NO_MEMORY;
                ldap_free_connection( ld, lc, 0, 0 );
@@ -516,7 +517,7 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
                        if ( lsu_port == lcu_port
                                && strcmp( lcu->lud_scheme, lsu->lud_scheme ) == 0
                                && lcu->lud_host != NULL && *lcu->lud_host != '\0'
-                           && lsu->lud_host != NULL && *lsu->lud_host != '\0'
+                               && lsu->lud_host != NULL && *lsu->lud_host != '\0'
                                && strcasecmp( lsu->lud_host, lcu->lud_host ) == 0 )
                        {
                                found = 1;
@@ -650,17 +651,17 @@ ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all )
        for ( lc = lconns; lc != NULL; lc = lc->lconn_next ) {
                if ( lc->lconn_server != NULL ) {
                        fprintf( stderr, "* host: %s  port: %d%s\n",
-                           ( lc->lconn_server->lud_host == NULL ) ? "(null)"
-                           : lc->lconn_server->lud_host,
-                           lc->lconn_server->lud_port, ( lc->lconn_sb ==
-                           ld->ld_sb ) ? "  (default)" : "" );
+                               ( lc->lconn_server->lud_host == NULL ) ? "(null)"
+                               : lc->lconn_server->lud_host,
+                               lc->lconn_server->lud_port, ( lc->lconn_sb ==
+                               ld->ld_sb ) ? "  (default)" : "" );
                }
                fprintf( stderr, "  refcnt: %d  status: %s\n", lc->lconn_refcnt,
-                   ( lc->lconn_status == LDAP_CONNST_NEEDSOCKET ) ?
-                   "NeedSocket" : ( lc->lconn_status ==
-                   LDAP_CONNST_CONNECTING ) ? "Connecting" : "Connected" );
+                       ( lc->lconn_status == LDAP_CONNST_NEEDSOCKET ) ?
+                       "NeedSocket" : ( lc->lconn_status ==
+                       LDAP_CONNST_CONNECTING ) ? "Connecting" : "Connected" );
                fprintf( stderr, "  last used: %s",
-                   ldap_pvt_ctime( &lc->lconn_lastused, timebuf ));
+                       ldap_pvt_ctime( &lc->lconn_lastused, timebuf ));
                if( lc->lconn_rebind_inprogress ) {
                        fprintf( stderr, "  rebind in progress\n");
                        if( lc->lconn_rebind_queue != NULL) {
@@ -698,34 +699,34 @@ ldap_dump_requests_and_responses( LDAP *ld )
                fprintf( stderr, "   Empty\n" );
        }
        for ( ; lr != NULL; lr = lr->lr_next ) {
-           fprintf( stderr, " * msgid %d,  origid %d, status %s\n",
-               lr->lr_msgid, lr->lr_origid,
-               ( lr->lr_status == LDAP_REQST_INPROGRESS ) ? "InProgress" :
-               ( lr->lr_status == LDAP_REQST_CHASINGREFS ) ? "ChasingRefs" :
-               ( lr->lr_status == LDAP_REQST_NOTCONNECTED ) ? "NotConnected" :
-               ( lr->lr_status == LDAP_REQST_WRITING ) ? "Writing" :
-               ( lr->lr_status == LDAP_REQST_COMPLETED ) ? "RequestCompleted"
-                       : "InvalidStatus");
-           fprintf( stderr, "   outstanding referrals %d, parent count %d\n",
-                   lr->lr_outrefcnt, lr->lr_parentcnt );
+               fprintf( stderr, " * msgid %d,  origid %d, status %s\n",
+                       lr->lr_msgid, lr->lr_origid,
+                       ( lr->lr_status == LDAP_REQST_INPROGRESS ) ? "InProgress" :
+                       ( lr->lr_status == LDAP_REQST_CHASINGREFS ) ? "ChasingRefs" :
+                       ( lr->lr_status == LDAP_REQST_NOTCONNECTED ) ? "NotConnected" :
+                       ( lr->lr_status == LDAP_REQST_WRITING ) ? "Writing" :
+                       ( lr->lr_status == LDAP_REQST_COMPLETED ) ? "RequestCompleted"
+                               : "InvalidStatus");
+               fprintf( stderr, "   outstanding referrals %d, parent count %d\n",
+                       lr->lr_outrefcnt, lr->lr_parentcnt );
        }
 #ifdef LDAP_R_COMPILE
        ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
 #endif
        fprintf( stderr, "** ld %p Response Queue:\n", (void *)ld );
-       if (( lm = ld->ld_responses ) == NULL ) {
+       if ( ( lm = ld->ld_responses ) == NULL ) {
                fprintf( stderr, "   Empty\n" );
        }
        for ( ; lm != NULL; lm = lm->lm_next ) {
                fprintf( stderr, " * msgid %d,  type %lu\n",
                    lm->lm_msgid, (unsigned long) lm->lm_msgtype );
-               if (( l = lm->lm_chain ) != NULL ) {
+               if ( ( l = lm->lm_chain ) != NULL ) {
                        fprintf( stderr, "   chained responses:\n" );
                        for ( ; l != NULL; l = l->lm_chain ) {
                                fprintf( stderr,
-                                   "  * msgid %d,  type %lu\n",
-                                   l->lm_msgid,
-                                   (unsigned long) l->lm_msgtype );
+                                       "  * msgid %d,  type %lu\n",
+                                       l->lm_msgid,
+                                       (unsigned long) l->lm_msgtype );
                        }
                }
        }
@@ -1413,7 +1414,7 @@ ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid )
        ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
 #endif
        for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
-               if( lr->lr_status == LDAP_REQST_COMPLETED ) {
+               if ( lr->lr_status == LDAP_REQST_COMPLETED ) {
                        continue;       /* Skip completed requests */
                }
                if ( msgid == lr->lr_msgid ) {
index 04e5fdb96aab709a397ab53193a4fdc5a70adfd3..8cfe81176eff1e8a4b2df23119a627023c78eab4 100644 (file)
@@ -278,7 +278,7 @@ wait4msg(
                }
 #endif /* LDAP_DEBUG */
 
-               if ( (*result = chkResponseList(ld, msgid, all)) != NULL ) {
+               if ( ( *result = chkResponseList( ld, msgid, all ) ) != NULL ) {
                        rc = (*result)->lm_msgtype;
 
                } else {
@@ -290,7 +290,8 @@ wait4msg(
                        for ( lc = ld->ld_conns; lc != NULL; lc = nextlc ) {
                                nextlc = lc->lconn_next;
                                if ( ber_sockbuf_ctrl( lc->lconn_sb,
-                                               LBER_SB_OPT_DATA_READY, NULL ) ) {
+                                               LBER_SB_OPT_DATA_READY, NULL ) )
+                               {
 #ifdef LDAP_R_COMPILE
                                        ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
 #endif
@@ -318,7 +319,7 @@ wait4msg(
 
                                if ( rc == 0 || ( rc == -1 && (
                                        !LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART)
-                                               || errno != EINTR )))
+                                               || errno != EINTR ) ) )
                                {
                                        ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
                                                LDAP_TIMEOUT);
@@ -348,7 +349,7 @@ wait4msg(
                                        {
                                                nextlc = lc->lconn_next;
                                                if ( lc->lconn_status == LDAP_CONNST_CONNECTED &&
-                                                       ldap_is_read_ready( ld, lc->lconn_sb ))
+                                                       ldap_is_read_ready( ld, lc->lconn_sb ) )
                                                {
 #ifdef LDAP_R_COMPILE
                                                        ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
@@ -437,7 +438,7 @@ try_read1msg(
 
 retry:
        if ( lc->lconn_ber == NULL ) {
-               lc->lconn_ber = ldap_alloc_ber_with_options(ld);
+               lc->lconn_ber = ldap_alloc_ber_with_options( ld );
 
                if( lc->lconn_ber == NULL ) {
                        return -1;
@@ -453,7 +454,7 @@ retry:
        if ( LDAP_IS_UDP(ld) ) {
                struct sockaddr from;
                ber_int_sb_read( lc->lconn_sb, &from, sizeof(struct sockaddr) );
-               if (ld->ld_options.ldo_version == LDAP_VERSION2) isv2=1;
+               if (ld->ld_options.ldo_version == LDAP_VERSION2) isv2 = 1;
        }
 nextresp3:
 #endif
@@ -509,7 +510,7 @@ retry_ber:
        if ( lr == NULL ) {
                Debug( LDAP_DEBUG_ANY,
                        "no request for response on ld %p msgid %ld (tossing)\n",
-                       (void *)ld, (long) id, 0 );
+                       (void *)ld, (long)id, 0 );
                goto retry_ber;
        }
 #ifdef LDAP_CONNECTIONLESS
@@ -562,7 +563,7 @@ nextresp2:
                                        if ( refer_cnt > 0 ) {
                                                /* sucessfully chased reference */
                                                /* If haven't got end search, set chasing referrals */
-                                               if( lr->lr_status != LDAP_REQST_COMPLETED) {
+                                               if ( lr->lr_status != LDAP_REQST_COMPLETED ) {
                                                        lr->lr_status = LDAP_REQST_CHASINGREFS;
                                                        Debug( LDAP_DEBUG_TRACE,
                                                                "read1msg:  search ref chased, "
@@ -620,7 +621,7 @@ nextresp2:
                                                         * Note: refs arrary is freed by ldap_chase_v3referrals
                                                         */
                                                        refer_cnt = ldap_chase_v3referrals( ld, lr, refs,
-                                                           0, &lr->lr_res_error, &hadref );
+                                                               0, &lr->lr_res_error, &hadref );
                                                        lr->lr_status = LDAP_REQST_COMPLETED;
                                                        Debug( LDAP_DEBUG_TRACE,
                                                                "read1msg: referral chased, mark request completed, ld %p msgid %d\n",
@@ -673,13 +674,11 @@ nextresp2:
                                != LBER_ERROR )
                        {
                                if ( lr_res_error != NULL ) {
-                                       {
-                                               if ( lr->lr_res_error != NULL ) {
-                                                       (void)ldap_append_referral( ld, &lr->lr_res_error, lr_res_error );
-                                                       LDAP_FREE( (char *)lr_res_error );
-                                               } else {
-                                                       lr->lr_res_error = lr_res_error;
-                                               }
+                                       if ( lr->lr_res_error != NULL ) {
+                                               (void)ldap_append_referral( ld, &lr->lr_res_error, lr_res_error );
+                                               LDAP_FREE( (char *)lr_res_error );
+                                       } else {
+                                               lr->lr_res_error = lr_res_error;
                                        }
                                        lr_res_error = NULL;
                                }
@@ -770,12 +769,12 @@ nextresp2:
 
                        /* Check if all requests are finished, lr is now parent */
                        tmplr = lr;
-                       if (tmplr->lr_status == LDAP_REQST_COMPLETED) {
+                       if ( tmplr->lr_status == LDAP_REQST_COMPLETED ) {
                                for ( tmplr=lr->lr_child;
                                        tmplr != NULL;
                                        tmplr=tmplr->lr_refnext)
                                {
-                                       if( tmplr->lr_status != LDAP_REQST_COMPLETED) break;
+                                       if ( tmplr->lr_status != LDAP_REQST_COMPLETED ) break;
                                }
                        }