binsearch: clarify variable name in greater-than-or-equal search
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 15 Dec 2016 01:39:33 +0000 (14:39 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 9 Feb 2017 02:17:15 +0000 (03:17 +0100)
The exact match variable was called "result" following the other
macros, which confused me for a moment.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/binsearch.h

index 001f2c51cd687a060c1ecade623704c2ba990988..454e5ce4742416d9123cc625f5bd1f218000e6d6 100644 (file)
   like BINARY_ARRAY_SEARCH_V, but if an exact result is not found, the 'next'
   argument will point to the element after the place where the exact result
   would have been. If an exact result is found, 'next' will be NULL. If the
-  target is beyond the end of the list, both 'result' and 'next' will be NULL.
+  target is beyond the end of the list, both 'exact' and 'next' will be NULL.
   Unlike other binsearch macros, where there are several elements that compare
-  the same, the result will always point to the first one.
+  the same, the exact result will always point to the first one.
 
   If you don't care to distinguish between the 'greater than' and 'equals'
-  cases, you can use the same pointer for both 'result' and 'next'.
+  cases, you can use the same pointer for both 'exact' and 'next'.
 
   As with all the binsearch macros, the comparison function is always called
   with the search term first.
  */
 #define BINARY_ARRAY_SEARCH_GTE(array, array_size, target, comparison_fn, \
-                               result, next) do {              \
+                               exact, next) do {               \
        int32_t _b, _e;                                         \
-       (result) = NULL; (next) = NULL;                 \
+       (exact) = NULL; (next) = NULL;                  \
        if ((array_size) > 0) {                                 \
                for (_b = 0, _e = (array_size)-1; _b <= _e; ) { \
                        int32_t _i = (_b + _e) / 2;                     \
                        int _r = comparison_fn(target, array[_i]); \
                        if (_r == 0) {                                  \
-                               (result) = &array[_i];                  \
+                               (exact) = &array[_i];                   \
                                _e = _i - 1;                            \
                        } else if (_r < 0) { _e = _i - 1;               \
                        } else  { _b = _i + 1; }                        \
                }                                                       \
-               if ((result) == NULL &&_b < (array_size)) {             \
+               if ((exact) == NULL &&_b < (array_size)) {              \
                        (next) = &array[_b];                            \
        } } } while (0)