]> git.sur5r.net Git - openldap/commitdiff
ITS#7168 cleanup prev commit
authorHoward Chu <hyc@openldap.org>
Mon, 25 Jun 2012 19:45:32 +0000 (12:45 -0700)
committerHoward Chu <hyc@openldap.org>
Mon, 25 Jun 2012 19:45:32 +0000 (12:45 -0700)
servers/slapd/overlays/constraint.c

index 538d38307f9e03ec3d7d0aedbda33d44ebdea01c..c3f9d66abf7771132c63790135786b8aa4937f22 100644 (file)
@@ -181,7 +181,7 @@ constraint_cf_gen( ConfigArgs *c )
                                }
 
                                if (cp->count || cp->size) {
-                                       int len = snprintf(val_buf, sizeof(val_buf), "%d", val);
+                                       int len = snprintf(val_buf, sizeof(val_buf), "%zd", val);
                                        if (len <= 0) {
                                                /* error */
                                                return -1;
@@ -846,40 +846,29 @@ constraint_check_count_violation( Modifications *m, Entry *target_entry, constra
        int j;
 
        for ( j = 0; cp->ap[j]; j++ ) {
-               ca = 0;
-
                /* Get this attribute count */
                if ( target_entry )
                        ce = constraint_count_attr( target_entry, cp->ap[j] );
 
                for( ; m; m = m->sml_next ) {
                        if ( cp->ap[j] == m->sml_desc ) {
+                               ca = m->sml_numvals;
                                switch ( m->sml_op ) {
                                case LDAP_MOD_DELETE:
-                                       if (( b = m->sml_values ) == NULL  || b[0].bv_val == NULL ) {
+                                       if ( !ca || ca > ce ) {
                                                ce = 0;
-                                       }
-                                       else {
+                                       } else {
                                                /* No need to check for values' validity. Invalid values
                                                 * cause the whole transaction to die anyway. */
-                                               for ( ca = 0; b[ca].bv_val; ++ca );
                                                ce -= ca;
                                        }
                                        break;
 
                                case LDAP_MOD_ADD:
-                                       if (( b = m->sml_values ) == NULL  || b[0].bv_val == NULL )
-                                               continue;
-
-                                       for ( ca = 0; b[ca].bv_val; ++ca );
                                        ce += ca;
                                        break;
 
                                case LDAP_MOD_REPLACE:
-                                       if (( b = m->sml_values ) == NULL  || b[0].bv_val == NULL )
-                                               continue;
-
-                                       for ( ca = 0; b[ca].bv_val; ++ca );
                                        ce = ca;
                                        break;