Modify apitest to test for non-zero instead of LDAP_OPT_ON.
{
ber_int_options.lbo_valid = LBER_INITIALIZED;
+ /* catch p == NULL when debugging */
assert( p != NULL );
+ /* ignore p == NULL when not debugging */
+ if( p == NULL ) {
+ return;
+ }
+
if( ber_int_memory_fns == NULL ) {
free( p );
return;
{
ber_int_options.lbo_valid = LBER_INITIALIZED;
+ /* catch s == 0 when debugging */
assert( s );
+ /* ignore s == 0 when not debugging */
+ if( s == 0 ) {
+ return NULL;
+ }
+
if( ber_int_memory_fns == NULL ) {
return malloc( s );
}
{
ber_int_options.lbo_valid = LBER_INITIALIZED;
+ /* catch s,n == 0 when debugging */
assert( n && s );
+ /* ignore s,n == 0 when not debugging */
+ if( n == 0 || s == 0 ) {
+ return NULL;
+ }
+
if( ber_int_memory_fns == NULL ) {
return calloc( n, s );
}
{
ber_int_options.lbo_valid = LBER_INITIALIZED;
+ /* realloc(NULL,s) -> malloc(s) */
if( p == NULL ) {
return ber_memalloc( s );
}
+ /* realloc(p,0) -> free(p) */
if( s == 0 ) {
ber_memfree( p );
return NULL;
fprintf(stderr, "%s: ldap_get_option(referrals) failed\n", argv[0]);
return EXIT_FAILURE;
}
- printf(" REFERRALS: %s\n",
- ival == (int) LDAP_OPT_ON ? "on" : "off");
+ printf(" REFERRALS: %s\n", ival ? "on" : "off");
if(ldap_get_option(NULL, LDAP_OPT_RESTART, &ival) != LDAP_SUCCESS) {
fprintf(stderr, "%s: ldap_get_option(restart) failed\n", argv[0]);
return EXIT_FAILURE;
}
- printf(" RESTART: %s\n",
- ival == (int) LDAP_OPT_ON ? "on" : "off");
+ printf(" RESTART: %s\n", ival ? "on" : "off");
if(ldap_get_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ival) != LDAP_SUCCESS) {
fprintf(stderr, "%s: ldap_get_option(protocol version) failed\n", argv[0]);
#define LDAP_BOOLEANS unsigned long
#define LDAP_BOOL(n) (1 << (n))
#define LDAP_BOOL_GET(lo, bool) ((lo)->ldo_booleans & LDAP_BOOL(bool) \
- ? LDAP_OPT_ON : LDAP_OPT_OFF)
+ ? -1 : 0)
#define LDAP_BOOL_SET(lo, bool) ((lo)->ldo_booleans |= LDAP_BOOL(bool))
#define LDAP_BOOL_CLR(lo, bool) ((lo)->ldo_booleans &= ~LDAP_BOOL(bool))
#define LDAP_BOOL_ZERO(lo) ((lo)->ldo_booleans = 0)
return LDAP_OPT_SUCCESS;
case LDAP_OPT_REFERRALS:
- * (int *) outvalue = (LDAP_BOOL_GET(lo, LDAP_BOOL_REFERRALS) ==
- LDAP_OPT_ON);
+ * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_REFERRALS);
return LDAP_OPT_SUCCESS;
case LDAP_OPT_RESTART:
- * (int *) outvalue = (LDAP_BOOL_GET(lo, LDAP_BOOL_RESTART) ==
- LDAP_OPT_ON);
+ * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_RESTART);
return LDAP_OPT_SUCCESS;
case LDAP_OPT_DNS: /* LDAPv2 */
- * (int *) outvalue = (LDAP_BOOL_GET(lo, LDAP_BOOL_DNS) ==
- LDAP_OPT_ON);
+ * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_DNS);
return LDAP_OPT_SUCCESS;
case LDAP_OPT_PROTOCOL_VERSION:
switch(option) {
case LDAP_OPT_REFERRALS:
- if(invalue == LDAP_OPT_ON) {
- LDAP_BOOL_SET(lo, LDAP_BOOL_REFERRALS);
- } else {
+ if(invalue == LDAP_OPT_OFF) {
LDAP_BOOL_CLR(lo, LDAP_BOOL_REFERRALS);
+ } else {
+ LDAP_BOOL_SET(lo, LDAP_BOOL_REFERRALS);
}
return LDAP_OPT_SUCCESS;
case LDAP_OPT_RESTART:
- if(invalue == LDAP_OPT_ON) {
- LDAP_BOOL_SET(lo, LDAP_BOOL_RESTART);
- } else {
+ if(invalue == LDAP_OPT_OFF) {
LDAP_BOOL_CLR(lo, LDAP_BOOL_RESTART);
+ } else {
+ LDAP_BOOL_SET(lo, LDAP_BOOL_RESTART);
}
return LDAP_OPT_SUCCESS;
}
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
- if (( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_DNS ) == LDAP_OPT_ON )
+ if ( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_DNS ))
&& ldap_is_dns_dn( dn ) )
{
if (( servers = dn2servers( ld, dn )) == NULL ) {
#endif
if ( rc == 0 || ( rc == -1 && (
- ( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART)
- == LDAP_OPT_OFF )
+ !LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART)
|| errno != EINTR )))
{
ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
if ( tag != LDAP_RES_SEARCH_ENTRY ) {
if ( ld->ld_version >= LDAP_VERSION2 &&
( lr->lr_parent != NULL ||
- ( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS)
- != LDAP_OPT_OFF ) ) )
+ LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) ) )
{
tmpber = *ber; /* struct copy */
if ( ber_scanf( &tmpber, "{iaa}", &lderr,