mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 12:34:55 +00:00
glib-aux: use nm_assert() in nm_{ptr,}array_find_bsearch()
These checks don't seem very useful, to have them enabled in production code. What is actually the real danger of messing up with binary search, is that the input array is not properly sorted. Asserting for that would be way more useful, but also likely too expensive to be worth it. Checking that the input arguments are not NULL/zero, is not that useful, because we "usually" won't make such mistakes. While at it, declare each local variable on a separate line.
This commit is contained in:
parent
1656d82045
commit
1c76fe418b
|
@ -3793,11 +3793,13 @@ nm_ptrarray_find_bsearch(gconstpointer *list,
|
|||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data)
|
||||
{
|
||||
gssize imin, imax, imid;
|
||||
gssize imax;
|
||||
gssize imid;
|
||||
gssize imin;
|
||||
int cmp;
|
||||
|
||||
g_return_val_if_fail(list || !len, ~((gssize) 0));
|
||||
g_return_val_if_fail(cmpfcn, ~((gssize) 0));
|
||||
nm_assert(list || len == 0);
|
||||
nm_assert(cmpfcn);
|
||||
|
||||
imin = 0;
|
||||
if (len > 0) {
|
||||
|
@ -3832,11 +3834,16 @@ nm_ptrarray_find_bsearch_range(gconstpointer *list,
|
|||
gssize *out_idx_first,
|
||||
gssize *out_idx_last)
|
||||
{
|
||||
gssize imin, imax, imid, i2min, i2max, i2mid;
|
||||
gssize imax;
|
||||
gssize imid;
|
||||
gssize imin;
|
||||
gssize i2max;
|
||||
gssize i2mid;
|
||||
gssize i2min;
|
||||
int cmp;
|
||||
|
||||
g_return_val_if_fail(list || !len, ~((gssize) 0));
|
||||
g_return_val_if_fail(cmpfcn, ~((gssize) 0));
|
||||
nm_assert(list || len == 0);
|
||||
nm_assert(cmpfcn);
|
||||
|
||||
imin = 0;
|
||||
if (len > 0) {
|
||||
|
@ -3936,12 +3943,14 @@ nm_array_find_bsearch(gconstpointer list,
|
|||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data)
|
||||
{
|
||||
gssize imin, imax, imid;
|
||||
gssize imax;
|
||||
gssize imid;
|
||||
gssize imin;
|
||||
int cmp;
|
||||
|
||||
g_return_val_if_fail(list || !len, ~((gssize) 0));
|
||||
g_return_val_if_fail(cmpfcn, ~((gssize) 0));
|
||||
g_return_val_if_fail(elem_size > 0, ~((gssize) 0));
|
||||
nm_assert(list || len == 0);
|
||||
nm_assert(cmpfcn);
|
||||
nm_assert(elem_size > 0);
|
||||
|
||||
imin = 0;
|
||||
if (len == 0)
|
||||
|
|
Loading…
Reference in a new issue