Issues (2963)

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

1
<?php
2
3
$datasetTable_array = snmpwalk_cache_oid($device, 'datasetTable', null, 'FREENAS-MIB');
0 ignored issues
show
Are you sure the assignment to $datasetTable_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` != 'dataset'";
6
$tmp_storage = dbFetchColumn($sql);
7
8
if (is_array($datasetTable_array)) {
0 ignored issues
show
The condition is_array($datasetTable_array) is always false.
Loading history...
9
    foreach ($datasetTable_array as $index => $dataset) {
10
        if (isset($dataset['datasetDescr'])) {
11
            if (! in_array($dataset['datasetDescr'], $tmp_storage)) {
12
                $dataset['datasetIndex'] = $index;
13
                $dataset['datasetTotal'] = $dataset['datasetSize'] * $dataset['datasetAllocationUnits'];
14
                $dataset['datasetAvail'] = ($dataset['datasetAvailable'] * $dataset['datasetAllocationUnits']);
15
                $dataset['datasetUsed'] = $dataset['datasetTotal'] - $dataset['datasetAvail'];
16
17
                discover_storage($valid_storage, $device, $dataset['datasetIndex'], 'dataset', 'freenas-dataset', $dataset['datasetDescr'], $dataset['datasetTotal'], $dataset['datasetAllocationUnits'], $dataset['datasetUsed']);
18
            }
19
        }
20
    }
21
}
22