cli: sort_access_points() doesn't take a NULL argument
authorLubomir Rintel <lkundrak@v3.sk>
Thu, 4 Feb 2016 15:42:00 +0000 (16:42 +0100)
committerLubomir Rintel <lkundrak@v3.sk>
Thu, 11 Feb 2016 16:01:03 +0000 (17:01 +0100)
The device never returns NULL access point list, it only deallocates it on
dispose(). Make this clear for Coverity:

CID 59387 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking aps suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.

clients/cli/devices.c

index c1df7fe..1b221a8 100644 (file)
@@ -587,8 +587,10 @@ sort_access_points (const GPtrArray *aps)
        GPtrArray *sorted;
        int i;
 
+       g_return_val_if_fail (aps, NULL);
+
        sorted = g_ptr_array_sized_new (aps->len);
-       for (i = 0; aps && i < aps->len; i++)
+       for (i = 0; i < aps->len; i++)
                g_ptr_array_add (sorted, aps->pdata[i]);
        g_ptr_array_sort_with_data (sorted, compare_aps, NULL);
        return sorted;