From: Hallvard Furuseth Date: Fri, 17 Oct 2008 16:34:04 +0000 (+0000) Subject: Warning cleanup: signed meets unsigned: Replace BVICMP() with !BV_CASEMATCH(). X-Git-Tag: ACLCHECK_0~1241 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9a542f526d0b7a073ef5dbf487b447272be439a0;p=openldap Warning cleanup: signed meets unsigned: Replace BVICMP() with !BV_CASEMATCH(). BVICMP() tried (unnecessarily) to return <0 / 0 / >0, but could be unsigned. --- diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 558cdb6bbf..9fef596368 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -95,8 +95,8 @@ static struct berval BV_NEWRDN = BER_BVC("newrdn"); static struct berval BV_DELETEOLDRDN = BER_BVC("deleteoldrdn"); static struct berval BV_NEWSUP = BER_BVC("newsuperior"); -#define BVICMP(a,b) ((a)->bv_len != (b)->bv_len ? \ - (a)->bv_len - (b)->bv_len : strcasecmp((a)->bv_val, (b)->bv_val)) +#define BV_CASEMATCH(a, b) \ + ((a)->bv_len == (b)->bv_len && 0 == strcasecmp((a)->bv_val, (b)->bv_val)) static int process_ldif_rec LDAP_P(( char *rbuf, int lineno )); static int parse_ldif_control LDAP_P(( struct berval *val, LDAPControl ***pctrls )); @@ -457,7 +457,7 @@ process_ldif_rec( char *rbuf, int linenum ) freeval[i] = freev; if ( dn == NULL ) { - if ( linenum+i == 1 && !BVICMP( btype+i, &BV_VERSION )) { + if ( linenum+i == 1 && BV_CASEMATCH( btype+i, &BV_VERSION )) { int v; if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) { fprintf( stderr, @@ -466,7 +466,7 @@ process_ldif_rec( char *rbuf, int linenum ) } version++; - } else if ( !BVICMP( btype+i, &BV_DN )) { + } else if ( BV_CASEMATCH( btype+i, &BV_DN )) { dn = vals[i].bv_val; idn = i; } @@ -494,7 +494,7 @@ process_ldif_rec( char *rbuf, int linenum ) i = idn+1; /* Check for "control" tag after dn and before changetype. */ - if (!BVICMP( btype+i, &BV_CONTROL)) { + if ( BV_CASEMATCH( btype+i, &BV_CONTROL )) { /* Parse and add it to the list of controls */ rc = parse_ldif_control( vals+i, &pctrls ); if (rc != 0) { @@ -515,7 +515,7 @@ short_input: } /* Check for changetype */ - if ( !BVICMP( btype+i, &BV_CHANGETYPE )) { + if ( BV_CASEMATCH( btype+i, &BV_CHANGETYPE )) { #ifdef LIBERAL_CHANGETYPE_MODOP /* trim trailing spaces (and log warning ...) */ int icnt; @@ -533,20 +533,20 @@ short_input: } #endif /* LIBERAL_CHANGETYPE_MODOP */ - if ( BVICMP( vals+i, &BV_MODIFYCT ) == 0 ) { + if ( BV_CASEMATCH( vals+i, &BV_MODIFYCT )) { new_entry = 0; expect_modop = 1; - } else if ( BVICMP( vals+i, &BV_ADDCT ) == 0 ) { + } else if ( BV_CASEMATCH( vals+i, &BV_ADDCT )) { new_entry = 1; modop = LDAP_MOD_ADD; - } else if ( BVICMP( vals+i, &BV_MODRDNCT ) == 0 - || BVICMP( vals+i, &BV_MODDNCT ) == 0 - || BVICMP( vals+i, &BV_RENAMECT ) == 0) + } else if ( BV_CASEMATCH( vals+i, &BV_MODRDNCT ) + || BV_CASEMATCH( vals+i, &BV_MODDNCT ) + || BV_CASEMATCH( vals+i, &BV_RENAMECT )) { i++; if ( i >= lines ) goto short_input; - if ( BVICMP( btype+i, &BV_NEWRDN )) { + if ( !BV_CASEMATCH( btype+i, &BV_NEWRDN )) { fprintf( stderr, _("%s: expecting \"%s:\" but saw" " \"%s:\" (line %d, entry \"%s\")\n"), prog, BV_NEWRDN.bv_val, btype[i].bv_val, linenum+i, dn ); @@ -557,7 +557,7 @@ short_input: i++; if ( i >= lines ) goto short_input; - if ( BVICMP( btype+i, &BV_DELETEOLDRDN )) { + if ( !BV_CASEMATCH( btype+i, &BV_DELETEOLDRDN )) { fprintf( stderr, _("%s: expecting \"%s:\" but saw" " \"%s:\" (line %d, entry \"%s\")\n"), prog, BV_DELETEOLDRDN.bv_val, btype[i].bv_val, linenum+i, dn ); @@ -567,7 +567,7 @@ short_input: deleteoldrdn = ( vals[i].bv_val[0] == '0' ) ? 0 : 1; i++; if ( i < lines ) { - if ( BVICMP( btype+i, &BV_NEWSUP )) { + if ( !BV_CASEMATCH( btype+i, &BV_NEWSUP )) { fprintf( stderr, _("%s: expecting \"%s:\" but saw" " \"%s:\" (line %d, entry \"%s\")\n"), prog, BV_NEWSUP.bv_val, btype[i].bv_val, linenum+i, dn ); @@ -578,7 +578,7 @@ short_input: i++; } got_all = 1; - } else if ( BVICMP( vals+i, &BV_DELETECT ) == 0 ) { + } else if ( BV_CASEMATCH( vals+i, &BV_DELETECT )) { got_all = delete_entry = 1; } else { fprintf( stderr, @@ -615,7 +615,7 @@ short_input: /* Make sure all attributes with multiple values are contiguous */ for (; i