Issues (2963)

includes/discovery/storage/freenas-zpool.inc.php (2 issues)

1
<?php
2
3
$zpooltable_array = snmpwalk_cache_oid($device, 'zpoolTable', null, 'FREENAS-MIB');
0 ignored issues
show
Are you sure the assignment to $zpooltable_array is correct as snmpwalk_cache_oid($devi...', null, 'FREENAS-MIB') seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
4
5
$sql = "SELECT `storage_descr` FROM `storage` WHERE `device_id`  = '" . $device['device_id'] . "' AND `storage_type` != 'zpool'";
6
$tmp_storage = dbFetchColumn($sql);
7
8
if (is_array($zpooltable_array)) {
0 ignored issues
show
The condition is_array($zpooltable_array) is always false.
Loading history...
9
    foreach ($zpooltable_array as $index => $zpool) {
10
        if (isset($zpool['zpoolDescr'])) {
11
            if (! in_array($zpool['zpoolDescr'], $tmp_storage)) {
12
                $zpool['zpoolIndex'] = $index;
13
                $zpool['zpoolTotal'] = $zpool['zpoolSize'] * $zpool['zpoolAllocationUnits'];
14
                $zpool['zpoolAvail'] = ($zpool['zpoolAvailable'] * $zpool['zpoolAllocationUnits']);
15
                $zpool['zpoolUsed'] = $zpool['zpoolTotal'] - $zpool['zpoolAvail'];
16
17
                discover_storage($valid_storage, $device, $zpool['zpoolIndex'], 'zpool', 'freenas-zpool', $zpool['zpoolDescr'], $zpool['zpoolTotal'], $zpool['zpoolAllocationUnits'], $zpool['zpoolUsed']);
18
            }
19
        }
20
    }
21
}
22