1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

F #6103: CppCheck version 2.10 - solved issues (#2492)

* Update smoke test checkout action
This commit is contained in:
Pavel Czerný 2023-02-13 17:31:51 +01:00 committed by GitHub
parent b36b173269
commit 466d336d7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 69 additions and 118 deletions

View File

@ -17,7 +17,7 @@ jobs:
- name: Install CppCheck
run: sudo apt install -y cppcheck
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# Runs a single command using the runners shell
- name: Run Smoke Tests

View File

@ -544,27 +544,27 @@ private:
* @param mac in string form 00:02:01:02:03:04
* @return 0 on success
*/
int mac_to_i(std::string mac, unsigned int i_mac[]) const;
static int mac_to_i(std::string mac, unsigned int i_mac[]);
/**
* MAC to string
* @param mac in array form
*/
std::string mac_to_s(const unsigned int mac[]) const;
static std::string mac_to_s(const unsigned int mac[]);
/**
* IP version 4 to binary (32 bits)
* @param ip in string form 192.168.0.2
* @return 0 on success
*/
int ip_to_i(const std::string& _ip, unsigned int& i_ip) const;
static int ip_to_i(const std::string& _ip, unsigned int& i_ip);
/**
* IP version 6 to binary (32 bits)
* @param ip string form 2a00:1bc0:b001:A::3
* @return 0 on success
*/
int ip6_to_i(const std::string& _ip, unsigned int i_ip[]) const;
static int ip6_to_i(const std::string& _ip, unsigned int i_ip[]);
/**
* IP version 4 to dot notation
@ -572,14 +572,14 @@ private:
* @param i_ip Numeric (32 bits) IP
* @return dot notation
*/
std::string ip_to_s(unsigned int i_ip) const;
static std::string ip_to_s(unsigned int i_ip);
/**
* IPv6 64bits prefix conversion
* @param prefix in string form 2a00:1bc0:b001:A::
* @return 0 on success
*/
int prefix6_to_i(const std::string& prefix, unsigned int ip[]) const;
static int prefix6_to_i(const std::string& prefix, unsigned int ip[]);
/**
* IPv6 to string
@ -588,10 +588,10 @@ private:
* @param ip6_s Will contain the resulting IPv6 string
* @return 0 on success
*/
int ip6_to_s(const unsigned int prefix[], const unsigned int mac[],
std::string& ip6_s) const;
static int ip6_to_s(const unsigned int prefix[], const unsigned int mac[],
std::string& ip6_s);
int ip6_to_s(const unsigned int ip6_i[], std::string& ip6_s) const;
static int ip6_to_s(const unsigned int ip6_i[], std::string& ip6_s);
/* ---------------------------------------------------------------------- */
/* NIC setup functions */

View File

@ -19,7 +19,6 @@
#include <time.h>
#include "NebulaLog.h"
#include "Listener.h"
#include "ProtocolMessages.h"
#include "DriverManager.h"

View File

@ -22,7 +22,6 @@
#include "ProtocolMessages.h"
#include "DriverManager.h"
#include "Listener.h"
#include "NebulaLog.h"
//Forward definitions
class IPAMRequest;

View File

@ -175,7 +175,7 @@ private:
/**
* Message fields
*/
E _type;
E _type = E::UNDEFINED;
std::string _status = std::string("-");

View File

@ -27,7 +27,6 @@
#include <sys/types.h>
#include <unistd.h>
#include "NebulaLog.h"
#include "SqlDB.h"
#include "ObjectSQL.h"

View File

@ -24,7 +24,6 @@
#include "DefaultQuotas.h"
#include "UserPool.h"
#include "Zone.h"
#include "NebulaLog.h"
class LogDB;
class FedLogDB;

View File

@ -1780,36 +1780,6 @@ private:
*/
std::string deploy_id;
/**
* Memory in MB used by the VM
*/
long int memory;
/**
* CPU usage (percent)
*/
int cpu;
/**
* Network usage, transmitted bytes
*/
long long net_tx;
/**
* Network usage, received bytes
*/
long long net_rx;
/**
* Network usage, received bytes
*/
long long disk_actual;
/**
* Network usage, received bytes
*/
long long disk_virtual;
/**
* History record, for the current host
*/

View File

@ -8,10 +8,6 @@
<id>noExplicitConstructor</id>
<fileName>*</fileName>
</suppress>
<suppress>
<id>missingInclude</id>
<fileName>*</fileName>
</suppress>
<suppress>
<id>danglingLifetime</id>
<fileName>*</fileName>
@ -32,6 +28,12 @@
<id>useStlAlgorithm</id>
<fileName>*</fileName>
</suppress>
<!-- Uncomment this for cppcheck version 2.10
<suppress>
<id>cstyleCast</id>
<fileName>*</fileName>
</suppress>
-->
<!-- Suppresions specific per file, false positives -->
<suppress>
<id>knownConditionTrueFalse</id>
@ -50,10 +52,6 @@
<fileName>src/hm/HookLog.cc</fileName>
<symbolName>query_output</symbolName>
</suppress>
<suppress>
<id>ctuuninitvar</id>
<fileName>src/sql/LogDB.cc</fileName>
</suppress>
<suppress>
<id>knownConditionTrueFalse</id>
<fileName>src/raft/ReplicaThread.cc</fileName>

View File

@ -17,8 +17,8 @@ SOURCES="src"
INCLUDES="-I include -I src/monitor/include -I src/scheduler/include"
DEFINES="-DSQLITE_DB -DMYSQL_DB -DPOSTGRESQL_DB -DSYSTEMD"
ENABLE="--enable=performance,information,warning,portability,style"
IGNORE="-i .xmlrpc_test/ -i src/sunstone/ -i src/svncterm_server/ -i src/fireedge -i src/parsers"
IGNORE="-i .xmlrpc_test/ -i src/sunstone/ -i src/svncterm_server/ -i src/fireedge -i src/parsers -i src/vmm/LibVirtDriverKVM.cc"
SUPRESS="--suppress-xml=share/smoke_tests/config/cppcheck-suppressions.xml"
OTHERS="--std=c++14 --error-exitcode=2 -q"
OTHERS="--std=c++14 --error-exitcode=2 -q -j 4"
cppcheck $SOURCES $INCLUDES $DEFINES $IGNORE $ENABLE $SUPRESS $OTHERS

View File

@ -336,7 +336,6 @@ namespace ssl_util
if ( rc != -1 )
{
result.append(out_c, rc);
rc = 0;
}
else
{

View File

@ -94,7 +94,7 @@ void Datastore::disk_attribute(
VirtualMachineDisk * disk,
const vector<string>& inherit_attrs)
{
string st, tm_mad;
string st, tm_mad_system;
string inherit_val;
disk->replace("DATASTORE", get_name());
@ -105,17 +105,17 @@ void Datastore::disk_attribute(
disk->replace("CLUSTER_ID", one_util::join(cluster_ids, ','));
tm_mad = disk->get_tm_mad_system();
tm_mad_system = disk->get_tm_mad_system();
if (!tm_mad.empty())
if (!tm_mad_system.empty())
{
tm_mad = one_util::trim(tm_mad);
one_util::toupper(tm_mad);
tm_mad_system = one_util::trim(tm_mad_system);
one_util::toupper(tm_mad_system);
}
if (!tm_mad.empty())
if (!tm_mad_system.empty())
{
get_template_attribute("CLONE_TARGET_" + tm_mad, st);
get_template_attribute("CLONE_TARGET_" + tm_mad_system, st);
if (st.empty())
{
@ -132,9 +132,9 @@ void Datastore::disk_attribute(
disk->replace("CLONE_TARGET", st);
}
if (!tm_mad.empty())
if (!tm_mad_system.empty())
{
get_template_attribute("LN_TARGET_" + tm_mad, st);
get_template_attribute("LN_TARGET_" + tm_mad_system, st);
if (st.empty())
{
@ -181,9 +181,9 @@ void Datastore::disk_attribute(
}
}
if (!tm_mad.empty())
if (!tm_mad_system.empty())
{
get_template_attribute("DISK_TYPE_" + tm_mad, st);
get_template_attribute("DISK_TYPE_" + tm_mad_system, st);
if (!st.empty())
{
@ -202,15 +202,15 @@ void Datastore::disk_attribute(
* 4. Default set to "raw"
*/
string type = disk->vector_value("TYPE");
string type_disk = disk->vector_value("TYPE");
one_util::toupper(type);
one_util::toupper(type_disk);
if (type!= "CDROM" && disk->is_volatile())
if (type_disk!= "CDROM" && disk->is_volatile())
{
string driver = get_ds_driver();
if (type == "FS") /* Volatile Datablock */
if (type_disk == "FS") /* Volatile Datablock */
{
if (!driver.empty()) /* DRIVER in TM_MAD_CONF or DS Template */
{

View File

@ -63,15 +63,15 @@ int HookStateImage::parse_template(Template * tmpl, std::string& error_str)
return -1;
}
Image::ImageState state = Image::str_to_state(state_str);
Image::ImageState st = Image::str_to_state(state_str);
if ( state == Image::INIT )
if ( st == Image::INIT )
{
error_str = "Invalid or unkown STATE condition: " + state_str;
return -1;
}
tmpl->replace("STATE", Image::state_to_str(state));
tmpl->replace("STATE", Image::state_to_str(st));
return 0;
}

View File

@ -287,8 +287,7 @@ void Host::update_wilds()
wild << ", ";
}
string wname;
wname = vatt->vector_value("VM_NAME");
string wname = vatt->vector_value("VM_NAME");
if (wname.empty())
{

View File

@ -340,9 +340,7 @@ void HostSharePCI::clear()
int HostSharePCI::get_pci_value(const char * name,
const VectorAttribute * pci_device, unsigned int &pci_value)
{
string temp;
temp = pci_device->vector_value(name);
string temp = pci_device->vector_value(name);
if (temp.empty())
{

View File

@ -141,7 +141,6 @@ void ImageManager::timer_action()
vector<int> datastores;
Nebula& nd = Nebula::instance();
DatastorePool * dspool = nd.get_dspool();
RaftManager * raftm = nd.get_raftm();
if ( !raftm->is_leader() && !raftm->is_solo() )
@ -176,7 +175,6 @@ void ImageManager::monitor_datastore(int ds_id)
bool shared;
Nebula& nd = Nebula::instance();
DatastorePool * dspool = nd.get_dspool();
Datastore::DatastoreType ds_type;

View File

@ -1143,14 +1143,11 @@ void Nebula::start(bool bootstrap_only)
lcm->init_managers();
marketm->init_managers();
}
// ---- Start the Request Manager & Information Manager----
// This modules recevie request from users / monitor and need to be
// started in last place when all systems are up
if (!cache)
{
if ( im->start() != 0 )
{
throw runtime_error("Could not start the Information Manager");

View File

@ -38,7 +38,7 @@ void PoolObjectAuth::get_acl_rules(AclRule& owner_rule,
if ( owner_u == 1 )
{
perm_rights = perm_rights | AuthRequest::USE;
perm_rights = AuthRequest::USE;
}
if ( owner_m == 1 )
@ -62,7 +62,7 @@ void PoolObjectAuth::get_acl_rules(AclRule& owner_rule,
if ( group_u == 1 )
{
perm_rights = perm_rights | AuthRequest::USE;
perm_rights = AuthRequest::USE;
}
if ( group_m == 1 )
@ -86,7 +86,7 @@ void PoolObjectAuth::get_acl_rules(AclRule& owner_rule,
if ( other_u == 1 )
{
perm_rights = perm_rights | AuthRequest::USE;
perm_rights = AuthRequest::USE;
}
if ( other_m == 1 )

View File

@ -879,7 +879,7 @@ void RaftManager::request_vote()
return;
}
}
else if ( success == true )
else // success == true
{
granted_votes++;

View File

@ -165,7 +165,7 @@ void VirtualMachineXML::init_attributes()
continue;
}
std::string reqs, rank;
std::string reqs, sched_rank;
int nic_id;
nic_template.get("NIC_ID", nic_id);
@ -190,9 +190,9 @@ void VirtualMachineXML::init_attributes()
the_nic->set_requirements(reqs);
}
if ( nic_template.get("SCHED_RANK", rank) )
if ( nic_template.get("SCHED_RANK", sched_rank) )
{
the_nic->set_rank(rank);
the_nic->set_rank(sched_rank);
}
}

View File

@ -574,7 +574,7 @@ int VirtualMachine::parse_context(string& error_str, bool all_nics)
ImagePool * ipool = nd.get_ipool();
Image::ImageType type;
Image::ImageState state;
Image::ImageState st;
for ( auto iid : img_ids )
{
@ -584,7 +584,7 @@ int VirtualMachine::parse_context(string& error_str, bool all_nics)
<< img->get_name() << "' ";
type = img->get_type();
state = img->get_state();
st = img->get_state();
if (type != Image::CONTEXT)
{
@ -593,7 +593,7 @@ int VirtualMachine::parse_context(string& error_str, bool all_nics)
return -1;
}
if ( state != Image::READY )
if ( st != Image::READY )
{
ostringstream oss;

View File

@ -958,11 +958,9 @@ void VirtualMachineDisks::release_images(int vmid, bool image_error,
{
long long original_size, size;
int rc;
/* ---------- Update size on source image if needed ------------- */
rc = (*it)->vector_value("SIZE", size);
rc += (*it)->vector_value("ORIGINAL_SIZE", original_size);
(*it)->vector_value("SIZE", size);
(*it)->vector_value("ORIGINAL_SIZE", original_size);
if ( size > original_size )
{

View File

@ -68,7 +68,7 @@ int VirtualMachine::set_os_file(VectorAttribute* os, const string& base_name,
int img_id;
Image::ImageType type;
Image::ImageState state;
Image::ImageState st;
DatastorePool * ds_pool = nd.get_dspool();
int ds_id;
@ -111,7 +111,7 @@ int VirtualMachine::set_os_file(VectorAttribute* os, const string& base_name,
return -1;
}
state = img->get_state();
st = img->get_state();
ds_id = img->get_ds_id();
type = img->get_type();
@ -138,7 +138,7 @@ int VirtualMachine::set_os_file(VectorAttribute* os, const string& base_name,
return -1;
}
if ( state != Image::READY )
if ( st != Image::READY )
{
ostringstream oss;

View File

@ -1714,12 +1714,12 @@ int LibVirtDriver::deployment_description_kvm(
if ( type == "spice" )
{
// Spice password must be 60 characters maximum
passwd = passwd.substr(0, VirtualMachine::MAX_SPICE_PASSWD_LENGTH);
passwd.resize(VirtualMachine::MAX_SPICE_PASSWD_LENGTH);
}
else if ( type == "vnc" )
{
// Vnc password must be 8 characters maximum
passwd = passwd.substr(0, VirtualMachine::MAX_VNC_PASSWD_LENGTH);
passwd.resize(VirtualMachine::MAX_VNC_PASSWD_LENGTH);
}
const_cast<VectorAttribute*>(graphics)->replace("PASSWD", passwd);
@ -1936,8 +1936,6 @@ int LibVirtDriver::deployment_description_kvm(
if ( iothreads > 0 )
{
file << " iothread=" << one_util::escape_xml_attr(iothread_actual);
iothread_actual = (iothread_actual % iothreads) + 1;
}
file << "/>" << endl;

View File

@ -160,10 +160,10 @@ int AddressRange::init_ipv6_static(string& error_msg)
if ( attr->vector_value("SIZE").empty() )
{
unsigned long int size = pl <= 64 ? std::numeric_limits<unsigned long int>::max()
unsigned long int s = pl <= 64 ? std::numeric_limits<unsigned long int>::max()
: 1UL << (128 - pl);
attr->replace("SIZE", size);
attr->replace("SIZE", s);
}
return 0;
@ -872,7 +872,7 @@ void AddressRange::to_xml(ostringstream &oss, const vector<int>& vms,
/* ************************************************************************** */
/* ************************************************************************** */
int AddressRange::mac_to_i(string mac, unsigned int i_mac[]) const
int AddressRange::mac_to_i(string mac, unsigned int i_mac[])
{
istringstream iss;
@ -915,7 +915,7 @@ int AddressRange::mac_to_i(string mac, unsigned int i_mac[]) const
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
string AddressRange::mac_to_s(const unsigned int i_mac[]) const
string AddressRange::mac_to_s(const unsigned int i_mac[])
{
ostringstream oss;
unsigned int temp_byte;
@ -951,7 +951,7 @@ string AddressRange::mac_to_s(const unsigned int i_mac[]) const
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int AddressRange::ip_to_i(const string& _ip, unsigned int& i_ip) const
int AddressRange::ip_to_i(const string& _ip, unsigned int& i_ip)
{
istringstream iss;
size_t pos=0;
@ -1000,7 +1000,7 @@ int AddressRange::ip_to_i(const string& _ip, unsigned int& i_ip) const
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
string AddressRange::ip_to_s(unsigned int i_ip) const
string AddressRange::ip_to_s(unsigned int i_ip)
{
ostringstream oss;
unsigned int temp_byte;
@ -1025,7 +1025,7 @@ string AddressRange::ip_to_s(unsigned int i_ip) const
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int AddressRange::ip6_to_i(const string& _ip, unsigned int i_ip[]) const
int AddressRange::ip6_to_i(const string& _ip, unsigned int i_ip[])
{
struct in6_addr s6;
@ -1052,7 +1052,7 @@ int AddressRange::ip6_to_i(const string& _ip, unsigned int i_ip[]) const
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int AddressRange::prefix6_to_i(const string& prefix, unsigned int ip[]) const
int AddressRange::prefix6_to_i(const string& prefix, unsigned int ip[])
{
struct in6_addr s6;
@ -1079,7 +1079,7 @@ int AddressRange::prefix6_to_i(const string& prefix, unsigned int ip[]) const
/* -------------------------------------------------------------------------- */
int AddressRange::ip6_to_s(const unsigned int prefix[],
const unsigned int mac[], string& ip6_s) const
const unsigned int mac[], string& ip6_s)
{
unsigned int eui64[2];
unsigned int mlow = mac[0];
@ -1108,7 +1108,7 @@ int AddressRange::ip6_to_s(const unsigned int prefix[],
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int AddressRange::ip6_to_s(const unsigned int ip6_i[], string& ip6_s) const
int AddressRange::ip6_to_s(const unsigned int ip6_i[], string& ip6_s)
{
struct in6_addr ip6;
char dst[INET6_ADDRSTRLEN];