From 53f884ac1db2b030d2435f837e84ba7d16ec8b72 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Wed, 29 Jul 2009 15:06:28 +0000 Subject: [PATCH] Remove useless asserts that will be re-assert()ed before the variable is used --- libraries/liblber/decode.c | 30 +------------------------- libraries/liblber/encode.c | 44 -------------------------------------- 2 files changed, 1 insertion(+), 73 deletions(-) diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index b687e75cc8..a0440c7899 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -146,9 +146,7 @@ ber_skip_tag( BerElement *ber, ber_len_t *len ) ber_len_t i, noctets; unsigned char netlen[sizeof(ber_len_t)]; - assert( ber != NULL ); assert( len != NULL ); - assert( LBER_VALID( ber ) ); /* * Any ber element looks like this: tag length contents. @@ -240,9 +238,7 @@ ber_getnint( { unsigned char buf[sizeof(ber_int_t)]; - assert( ber != NULL ); assert( num != NULL ); - assert( LBER_VALID( ber ) ); /* * The tag and length have already been stripped off. We should @@ -288,9 +284,6 @@ ber_get_int( ber_tag_t tag; ber_len_t len; - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) { return LBER_DEFAULT; } @@ -319,9 +312,6 @@ ber_get_stringb( ber_len_t datalen; ber_tag_t tag; - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT ) { return LBER_DEFAULT; } @@ -487,11 +477,8 @@ ber_get_stringbv( BerElement *ber, struct berval *bv, int option ) { ber_tag_t tag; - assert( ber != NULL ); assert( bv != NULL ); - assert( LBER_VALID( ber ) ); - if ( (tag = ber_skip_tag( ber, &bv->bv_len )) == LBER_DEFAULT ) { bv->bv_val = NULL; return LBER_DEFAULT; @@ -531,11 +518,8 @@ ber_get_stringbv_null( BerElement *ber, struct berval *bv, int option ) { ber_tag_t tag; - assert( ber != NULL ); assert( bv != NULL ); - assert( LBER_VALID( ber ) ); - if ( (tag = ber_skip_tag( ber, &bv->bv_len )) == LBER_DEFAULT ) { bv->bv_val = NULL; return LBER_DEFAULT; @@ -636,12 +620,9 @@ ber_get_bitstringa( ber_tag_t tag; unsigned char unusedbits; - assert( ber != NULL ); assert( buf != NULL ); assert( blen != NULL ); - assert( LBER_VALID( ber ) ); - if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT ) { *buf = NULL; return LBER_DEFAULT; @@ -676,9 +657,6 @@ ber_get_null( BerElement *ber ) ber_len_t len; ber_tag_t tag; - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) { return LBER_DEFAULT; } @@ -699,11 +677,8 @@ ber_get_boolean( ber_int_t longbool; ber_tag_t rc; - assert( ber != NULL ); assert( boolval != NULL ); - assert( LBER_VALID( ber ) ); - rc = ber_get_int( ber, &longbool ); *boolval = longbool; @@ -716,8 +691,6 @@ ber_first_element( ber_len_t *len, char **last ) { - assert( ber != NULL ); - assert( len != NULL ); assert( last != NULL ); /* skip the sequence header, use the len to mark where to stop */ @@ -745,7 +718,6 @@ ber_next_element( assert( ber != NULL ); assert( len != NULL ); assert( last != NULL ); - assert( LBER_VALID( ber ) ); if ( ber->ber_ptr >= last ) { @@ -775,7 +747,6 @@ ber_scanf ( BerElement *ber, assert( ber != NULL ); assert( fmt != NULL ); - assert( LBER_VALID( ber ) ); fmt_reset = fmt; @@ -944,6 +915,7 @@ ber_scanf ( BerElement *ber, } va_end( ap ); + if ( rc == LBER_DEFAULT ) { /* * Error. Reclaim malloced memory that was given to the caller. diff --git a/libraries/liblber/encode.c b/libraries/liblber/encode.c index 24ac085fc6..a89eb28a67 100644 --- a/libraries/liblber/encode.c +++ b/libraries/liblber/encode.c @@ -247,9 +247,6 @@ ber_put_int_or_enum( ber_uint_t unum, mask; unsigned char netnum[sizeof(ber_uint_t)]; - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - sign = (num < 0); unum = num; /* Bit fiddling should be done with unsigned values */ @@ -307,9 +304,6 @@ ber_put_enum( ber_int_t num, ber_tag_t tag ) { - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( tag == LBER_DEFAULT ) { tag = LBER_ENUMERATED; } @@ -323,9 +317,6 @@ ber_put_int( ber_int_t num, ber_tag_t tag ) { - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( tag == LBER_DEFAULT ) { tag = LBER_INTEGER; } @@ -342,11 +333,6 @@ ber_put_ostring( { int taglen, lenlen, rc; - assert( ber != NULL ); - assert( str != NULL ); - - assert( LBER_VALID( ber ) ); - if ( tag == LBER_DEFAULT ) { tag = LBER_OCTETSTRING; } @@ -372,9 +358,6 @@ ber_put_berval( struct berval *bv, ber_tag_t tag ) { - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if( bv == NULL || bv->bv_len == 0 ) { return ber_put_ostring( ber, "", (ber_len_t) 0, tag ); } @@ -388,11 +371,8 @@ ber_put_string( LDAP_CONST char *str, ber_tag_t tag ) { - assert( ber != NULL ); assert( str != NULL ); - assert( LBER_VALID( ber ) ); - return ber_put_ostring( ber, str, strlen( str ), tag ); } @@ -407,11 +387,6 @@ ber_put_bitstring( ber_len_t len; unsigned char unusedbits; - assert( ber != NULL ); - assert( str != NULL ); - - assert( LBER_VALID( ber ) ); - if ( tag == LBER_DEFAULT ) { tag = LBER_BITSTRING; } @@ -443,9 +418,6 @@ ber_put_null( BerElement *ber, ber_tag_t tag ) { int taglen; - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( tag == LBER_DEFAULT ) { tag = LBER_NULL; } @@ -470,9 +442,6 @@ ber_put_boolean( int taglen; unsigned char c; - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( tag == LBER_DEFAULT ) tag = LBER_BOOLEAN; @@ -531,9 +500,6 @@ ber_start_seqorset( int ber_start_seq( BerElement *ber, ber_tag_t tag ) { - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( tag == LBER_DEFAULT ) { tag = LBER_SEQUENCE; } @@ -544,9 +510,6 @@ ber_start_seq( BerElement *ber, ber_tag_t tag ) int ber_start_set( BerElement *ber, ber_tag_t tag ) { - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - if ( tag == LBER_DEFAULT ) { tag = LBER_SET; } @@ -716,18 +679,12 @@ ber_put_seqorset( BerElement *ber ) int ber_put_seq( BerElement *ber ) { - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - return ber_put_seqorset( ber ); } int ber_put_set( BerElement *ber ) { - assert( ber != NULL ); - assert( LBER_VALID( ber ) ); - return ber_put_seqorset( ber ); } @@ -747,7 +704,6 @@ ber_printf( BerElement *ber, LDAP_CONST char *fmt, ... ) assert( ber != NULL ); assert( fmt != NULL ); - assert( LBER_VALID( ber ) ); va_start( ap, fmt ); -- 2.39.5