From: Howard Chu Date: Fri, 16 Sep 2005 01:56:36 +0000 (+0000) Subject: Fix prev commit, BIG_ENDIAN was broken X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~416 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3a9814e72568e84eacfd13f28f51b1a5664dfc61;p=openldap Fix prev commit, BIG_ENDIAN was broken --- diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index 2ec368c244..113f19d627 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -1387,7 +1387,8 @@ void bdb_idl_sort( ID *ids, ID *tmp ) { int count, soft_limit, phase = 0, size = ids[0]; - ID *idls[2], mask, maxval = ids[size]; + ID *idls[2]; + unsigned char *maxv = (unsigned char *)&ids[size]; if ( BDB_IDL_IS_RANGE( ids )) return; @@ -1412,17 +1413,15 @@ bdb_idl_sort( ID *ids, ID *tmp ) idls[0] = ids; idls[1] = tmp; - soft_limit = sizeof(ID) - 1; - mask = (ID)0xff << (sizeof(ID) - 1) * 8; - - while (!(maxval & mask)) { - soft_limit--; - mask >>= 8; - } +#if BYTE_ORDER == BIG_ENDIAN + for (soft_limit = 0; !maxv[soft_limit]; soft_limit++); +#else + for (soft_limit = sizeof(ID)-1; !maxv[soft_limit]; soft_limit--); +#endif for ( #if BYTE_ORDER == BIG_ENDIAN - count = soft_limit; count >= 0; --count + count = sizeof(ID)-1; count >= soft_limit; --count #else count = 0; count <= soft_limit; ++count #endif