Issues (2963)

includes/discovery/storage/datadomain.inc.php (2 issues)

1
<?php
2
/*
3
 * This program is free software: you can redistribute it and/or modify it
4
 * under the terms of the GNU General Public License as published by the
5
 * Free Software Foundation, either version 3 of the License, or (at your
6
 * option) any later version.  Please see LICENSE.txt at the top level of
7
 * the source code distribution for details.
8
9
 * @package    LibreNMS
10
 * @link       https://www.librenms.org
11
 * @copyright  2019 ACL
12
 * @author     Abel Laura <[email protected]>
13
*/
14
15
$ddos_storage = snmpwalk_cache_oid($device, 'fileSystemSpaceTable', null, 'DATA-DOMAIN-MIB', 'datadomain');
0 ignored issues
show
Are you sure the assignment to $ddos_storage is correct as snmpwalk_cache_oid($devi...AIN-MIB', 'datadomain') 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...
16
if (is_array($ddos_storage)) {
0 ignored issues
show
The condition is_array($ddos_storage) is always false.
Loading history...
17
    foreach ($ddos_storage as $index => $storage) {
18
        $fstype = $storage['fileSystemResourceTier'];
19
        $descr = $storage['fileSystemResourceName'];
20
        $units = 1073741824;
21
        $total = $storage['fileSystemSpaceSize'] * $units;
22
        $used = $storage['fileSystemSpaceUsed'] * $units;
23
        if ($descr == '/data: post-comp') {
24
            discover_storage($valid_storage, $device, $index, $fstype, 'datadomain', $descr, $total, $units, $used);
25
        }
26
    }
27
}
28
unset($fstype, $descr, $total, $used, $units, $ddos_storage);
29