]> git.sur5r.net Git - openldap/commitdiff
cleanup
authorPierangelo Masarati <ando@openldap.org>
Fri, 31 Jan 2003 00:02:51 +0000 (00:02 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 31 Jan 2003 00:02:51 +0000 (00:02 +0000)
servers/slapd/add.c

index 5c983676c89327bbb74e9ec72a958c947683ebba..8bb5c4fb449720679de8859fdf3b3c1ac842635d 100644 (file)
@@ -45,7 +45,7 @@ do_add( Connection *conn, Operation *op )
        Backend         *be;
        Modifications   *modlist = NULL;
        Modifications   **modtail = &modlist;
-       Modifications   tmp, *mod;
+       Modifications   tmp;
        const char *text;
        LDAPRDN         *rdn = NULL;
        int             cnt;
@@ -201,134 +201,133 @@ do_add( Connection *conn, Operation *op )
                goto done;
        }
 
-       if ( mod->sml_bvalues[ cnt ].bv_val == NULL ) {
-               /*
-                * Get attribute type(s) and attribute value(s) of our rdn,
-                */
-               if ( ldap_bv2rdn( &e->e_name, &rdn, (char **)&text,
-                       LDAP_DN_FORMAT_LDAP ) )
-               {
-                       send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX,
-                               NULL, "unknown type(s) used in RDN",
-                               NULL, NULL );
+       /*
+        * Get attribute type(s) and attribute value(s) of our rdn,
+        */
+       if ( ldap_bv2rdn( &e->e_name, &rdn, (char **)&text,
+               LDAP_DN_FORMAT_LDAP ) )
+       {
+               send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX,
+                       NULL, "unknown type(s) used in RDN",
+                       NULL, NULL );
+               goto done;
+       }
+
+       /* Check for RDN attrs in entry */
+       for ( cnt = 0; rdn[ 0 ][ cnt ]; cnt++ ) {
+               AttributeDescription    *desc = NULL;
+               Modifications           *mod;
+               MatchingRule            *mr;
+               int                     i;
+
+               rc = slap_bv2ad( &rdn[ 0 ][ cnt ]->la_attr, 
+                               &desc, &text );
+
+               if ( rc != LDAP_SUCCESS ) {
+                       send_ldap_result( conn, op, rc,
+                                       NULL, text, NULL, NULL );
                        goto done;
                }
 
-               /* Check for RDN attrs in entry */
-               for ( cnt = 0; rdn[ 0 ][ cnt ]; cnt++ ) {
-                       AttributeDescription    *desc = NULL;
-                       MatchingRule            *mr;
-                       int                     i;
-       
-                       rc = slap_bv2ad( &rdn[ 0 ][ cnt ]->la_attr, 
-                                       &desc, &text );
-       
+               for (mod = modlist; mod; mod = mod->sml_next) {
+                       AttributeDescription    *mod_desc = NULL;
+
+                       rc = slap_bv2ad( &mod->sml_type, 
+                                       &mod_desc, &text );
                        if ( rc != LDAP_SUCCESS ) {
                                send_ldap_result( conn, op, rc,
                                                NULL, text, NULL, NULL );
                                goto done;
                        }
-       
-                       for (mod = modlist; mod; mod = mod->sml_next) {
-                               AttributeDescription    *mod_desc = NULL;
-       
-                               rc = slap_bv2ad( &mod->sml_type, 
-                                               &mod_desc, &text );
-                               if ( rc != LDAP_SUCCESS ) {
-                                       send_ldap_result( conn, op, rc,
-                                                       NULL, text, NULL, NULL );
-                                       goto done;
-                               }
-       
-                               if (mod_desc == desc) {
-                                       break;
-                               }
+
+                       if (mod_desc == desc) {
+                               break;
                        }
-       
-                       if (mod == NULL) {
+               }
+
+               if (mod == NULL) {
 #define BAILOUT
 #ifdef BAILOUT
-                               /* bail out */
-                               send_ldap_result( conn, op, 
-                                       rc = LDAP_NO_SUCH_ATTRIBUTE,
-                                       NULL,
-                                       "RDN attribute value assertion not present in entry", 
-                                       NULL, NULL );
-                               goto done;
-       
+                       /* bail out */
+                       send_ldap_result( conn, op, 
+                               rc = LDAP_NO_SUCH_ATTRIBUTE,
+                               NULL,
+                               "RDN attribute value assertion not present in entry", 
+                               NULL, NULL );
+                       goto done;
+
 #else /* ! BAILOUT */
-                               struct berval   bv;
+                       struct berval   bv;
        
-                               /* add attribute type and value to modlist */
-                               mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
-                       
-                               mod->sml_op = LDAP_MOD_ADD;
-                               mod->sml_next = NULL;
-                               mod->sml_desc = NULL;
-       
-                               ber_dupbv( &mod->sml_type,
-                                               &rdn[ 0 ][ cnt ]->la_attr );
-       
-                               mod->sml_bvalues = NULL;
-                               ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
-                               ber_bvarray_add( &mod->sml_bvalues, &bv );
-       
-                               *modtail = mod;
-                               modtail = &mod->sml_next;
-                               continue;
+                       /* add attribute type and value to modlist */
+                       mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
+               
+                       mod->sml_op = LDAP_MOD_ADD;
+                       mod->sml_next = NULL;
+                       mod->sml_desc = NULL;
+
+                       ber_dupbv( &mod->sml_type,
+                                       &rdn[ 0 ][ cnt ]->la_attr );
+
+                       mod->sml_bvalues = NULL;
+                       ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
+                       ber_bvarray_add( &mod->sml_bvalues, &bv );
+
+                       *modtail = mod;
+                       modtail = &mod->sml_next;
+                       continue;
 #endif /* ! BAILOUT */
-                       }
-       
-                       mr = desc->ad_type->sat_equality;
-                       if (mr == NULL || !mr->smr_match ) {
-                               /* bail out */
-                               send_ldap_result( conn, op, 
-                                               rc = LDAP_INVALID_SYNTAX,
-                                               NULL,
-                                               "attribute in RDN lacks matching rule", 
-                                               NULL, NULL );
+               }
+
+               mr = desc->ad_type->sat_equality;
+               if (mr == NULL || !mr->smr_match ) {
+                       /* bail out */
+                       send_ldap_result( conn, op, 
+                                       rc = LDAP_INVALID_SYNTAX,
+                                       NULL,
+                                       "attribute in RDN lacks matching rule", 
+                                       NULL, NULL );
+                       goto done;
+               }
+
+               for (i = 0; mod->sml_bvalues[ i ].bv_val; i++) {
+                       int             match = 0;
+                       
+                       rc = value_match(&match, desc, mr,
+                                       SLAP_MR_VALUE_SYNTAX_MATCH,
+                                       &mod->sml_bvalues[ i ],
+                                       &rdn[ 0 ][ cnt ]->la_value, &text);
+
+                       if ( rc != LDAP_SUCCESS ) {
+                               send_ldap_result( conn, op, rc,
+                                               NULL, text, NULL, NULL);
                                goto done;
                        }
-       
-                       for (i = 0; mod->sml_bvalues[ i ].bv_val; i++) {
-                               int             match = 0;
-                               
-                               rc = value_match(&match, desc, mr,
-                                               SLAP_MR_VALUE_SYNTAX_MATCH,
-                                               &mod->sml_bvalues[ i ],
-                                               &rdn[ 0 ][ cnt ]->la_value, &text);
-       
-                               if ( rc != LDAP_SUCCESS ) {
-                                       send_ldap_result( conn, op, rc,
-                                                       NULL, text, NULL, NULL);
-                                       goto done;
-                               }
-       
-                               if (match == 0) {
-                                       break;
-                               }
+
+                       if (match == 0) {
+                               break;
                        }
-       
-                       /* not found? */
-                       if (mod->sml_bvalues[ i ].bv_val == NULL) {
+               }
+
+               /* not found? */
+               if (mod->sml_bvalues[ i ].bv_val == NULL) {
 #ifdef BAILOUT
-                               /* bailout */
-                               send_ldap_result( conn, op, 
-                                               rc = LDAP_NO_SUCH_ATTRIBUTE,
-                                               NULL,
-                                               "value in RDN not listed in entry", 
-                                               NULL, NULL );
-                               goto done;
-       
+                       /* bailout */
+                       send_ldap_result( conn, op, 
+                                       rc = LDAP_NO_SUCH_ATTRIBUTE,
+                                       NULL,
+                                       "value in RDN not listed in entry", 
+                                       NULL, NULL );
+                       goto done;
+
 #else /* ! BAILOUT */
-                               struct berval   bv;
-       
-                               /* add attribute type and value to modlist */
-                               ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
-                               ber_bvarray_add( &mod->sml_bvalues, &bv );
-                               continue;
+                       struct berval   bv;
+
+                       /* add attribute type and value to modlist */
+                       ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
+                       ber_bvarray_add( &mod->sml_bvalues, &bv );
+                       continue;
 #endif /* ! BAILOUT */
-                       }
                }
        }