src: fix a few minor coverty reports

This commit is contained in:
Franco Fichtner 2022-11-15 10:19:19 +01:00
parent c1347533c1
commit 272c231c70
10 changed files with 56 additions and 63 deletions

View File

@ -186,7 +186,7 @@ class VipSettingsController extends ApiMutableModelControllerBase
throw new UserException(implode('<br/>', array_slice($validations, 0, 5)), gettext("Item in use by"));
}
$response = $this->delBase("vip", $uuid);
if ($response['result'] ?? '' == 'deleted' && !file_exists("/tmp/delete_vip_{$uuid}.todo")) {
if (($response['result'] ?? '') == 'deleted' && !file_exists("/tmp/delete_vip_{$uuid}.todo")) {
file_put_contents("/tmp/delete_vip_{$uuid}.todo", (string)$node->subnet);
}
return $response;

View File

@ -333,11 +333,8 @@ class LDAP extends Base implements IAuthConnector
public function connect($bind_url, $userdn = null, $password = null, $timeout = 30)
{
$retval = false;
set_error_handler(
function () {
null;
}
);
set_error_handler(function () { /* do nothing */ });
$this->closeLDAPHandle();

View File

@ -1,32 +1,30 @@
<?php
/**
* Copyright (C) 2018 Deciso B.V.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Copyright (C) 2018 Deciso B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\Backup;
@ -60,7 +58,7 @@ class BackupFactory
);
}
} catch (\ReflectionException $e) {
null; // skip when unable to parse
/* skip when unable to parse */
}
}
return $providers;

View File

@ -1,31 +1,29 @@
<?php
/**
* Copyright (C) 2018 Deciso B.V.
/*
* Copyright (C) 2018 Deciso B.V.
* All rights reserved.
*
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\Backup;
@ -154,7 +152,7 @@ class Gdrive extends Base implements IBackupProvider
$config->system->remotebackup->$fieldname = base64_encode($conf[$field['name']]);
}
} elseif ($field['name'] == 'GDrivePasswordConfirm') {
null; // skip password confirm field
/* skip password confirm field */
} elseif (!empty($conf[$field['name']])) {
$config->system->remotebackup->$fieldname = $conf[$field['name']];
} else {

View File

@ -58,7 +58,7 @@ class ExportFactory
);
}
} catch (\ReflectionException $e) {
null; // skip when unable to parse
/* skip when unable to parse */
}
}
return $providers;

View File

@ -258,8 +258,7 @@ class Gateways
}
}
if (!empty($thisconf['virtual']) && in_array($thisconf['name'], $reservednames)) {
// if name is already taken, don't try to add a new (virtual) entry
null;
/* if name is already taken, don't try to add a new (virtual) entry */
} elseif (($router = $this->getRouterFromFile($realif, $ipproto)) != null) {
$thisconf['gateway'] = $router;
if (empty($thisconf['monitor_disable']) && empty($thisconf['monitor'])) {

View File

@ -477,7 +477,7 @@ abstract class BaseField
return $constr_class->newInstance($constraint);
}
} catch (ReflectionException $e) {
null; // ignore configuration errors, if the constraint can't be found, skip.
/* ignore configuration errors, if the constraint can't be found, skip. */
}
}
}

View File

@ -71,7 +71,7 @@ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir
}
}
} catch (\ReflectionException $e) {
null; // cannot construct, skip
/* cannot construct, skip */
}
}
}

View File

@ -65,7 +65,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_GET['id']) && !empty($a_domainOverrides[$_POST['id']])) {
if (isset($_POST['id']) && !empty($a_domainOverrides[$_POST['id']])) {
$id = $_POST['id'];
}
$input_errors= array();

View File

@ -225,6 +225,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (($pconfig['localid_netbits'] != 0 && !$pconfig['localid_netbits']) || !is_numeric($pconfig['localid_netbits'])) {
$input_errors[] = gettext('A valid local network bit count must be specified.');
}
/* FALLTHROUGH */
case 'address':
if (!$pconfig['localid_address'] || !is_ipaddr($pconfig['localid_address'])) {
$input_errors[] = gettext('A valid local network IP address must be specified.');