From 7e687b9a58070d1c35eca6c8471c2422c93719cc Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 5 Sep 2020 19:29:49 +0200 Subject: [PATCH] M #-: Fix compilation warnings --- include/AclManager.h | 24 ++++++++++++------------ include/VirtualMachine.h | 4 ++-- include/VirtualMachineTemplate.h | 10 ++++++++++ src/acl/AclManager.cc | 12 ++++++------ src/host/HostShareNUMA.cc | 10 ++++++---- src/monitor/include/Driver.h | 2 +- src/rm/RequestManager.cc | 4 +++- src/scheduler/include/SchedulerPolicy.h | 2 +- src/vnm/AddressRange.cc | 8 ++++---- 9 files changed, 45 insertions(+), 31 deletions(-) diff --git a/include/AclManager.h b/include/AclManager.h index c85f7c1e4b..37dbdcfd14 100644 --- a/include/AclManager.h +++ b/include/AclManager.h @@ -79,10 +79,10 @@ public: * @param op The operation to be authorized * @return true if the authorization is granted by any rule */ - const bool authorize(int uid, - const set& user_groups, - const PoolObjectAuth& obj_perms, - AuthRequest::Operation op); + bool authorize(int uid, + const set& user_groups, + const PoolObjectAuth& obj_perms, + AuthRequest::Operation op) const; /** * Takes an authorization request for oneadmin @@ -92,8 +92,8 @@ public: * @param op The operation to be authorized * @return true if the authorization is granted for oneadmin */ - const bool oneadmin_authorize(const PoolObjectAuth& obj_perms, - AuthRequest::Operation op); + bool oneadmin_authorize(const PoolObjectAuth& obj_perms, + AuthRequest::Operation op) const; /** * Adds a new rule to the ACL rule set @@ -285,7 +285,7 @@ private: long long resource_oid_mask, long long resource_gid_mask, long long resource_cid_mask, - const multimap& rules); + const multimap& rules) const; /** * Wrapper for match_rules. It will check if any rules in the temporary * multimap or in the internal one grants permission. @@ -313,7 +313,7 @@ private: long long individual_obj_type, long long group_obj_type, long long cluster_obj_type, - const multimap &tmp_rules); + const multimap &tmp_rules) const; /** * Deletes all rules that match the user mask * @@ -353,17 +353,17 @@ private: /** * Function to lock the manager */ - void lock() + void lock() const { - pthread_mutex_lock(&mutex); + pthread_mutex_lock(const_cast(&mutex)); }; /** * Function to unlock the manager */ - void unlock() + void unlock() const { - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(const_cast(&mutex)); }; // ------------------------------------------------------------------------- diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index f98a0253b7..38d6afa119 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -634,7 +634,7 @@ public: * function MUST be called before this one. * @return the action that closed the current history record */ - const VMActions::Action get_action() const + VMActions::Action get_action() const { return history->action; }; @@ -643,7 +643,7 @@ public: * Returns the action that closed the history record in the previous host * @return the action that closed the history record in the previous host */ - const VMActions::Action get_previous_action() const + VMActions::Action get_previous_action() const { return previous_history->action; }; diff --git a/include/VirtualMachineTemplate.h b/include/VirtualMachineTemplate.h index 66a9fd7bee..ac1a788b4e 100644 --- a/include/VirtualMachineTemplate.h +++ b/include/VirtualMachineTemplate.h @@ -41,6 +41,16 @@ public: VirtualMachineTemplate(VirtualMachineTemplate& vmt):Template(vmt){}; + VirtualMachineTemplate& operator=(const VirtualMachineTemplate& t) + { + if (this != &t) + { + Template::operator=(t); + } + + return *this; + } + void set_xml_root(const char * _xml_root) { Template::set_xml_root(_xml_root); diff --git a/src/acl/AclManager.cc b/src/acl/AclManager.cc index 239d4a16ce..d541b979b4 100644 --- a/src/acl/AclManager.cc +++ b/src/acl/AclManager.cc @@ -217,11 +217,11 @@ AclManager::~AclManager() /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -const bool AclManager::authorize( +bool AclManager::authorize( int uid, const set& user_groups, const PoolObjectAuth& obj_perms, - AuthRequest::Operation op) + AuthRequest::Operation op) const { bool auth = false; @@ -420,9 +420,9 @@ const bool AclManager::authorize( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -const bool AclManager::oneadmin_authorize( +bool AclManager::oneadmin_authorize( const PoolObjectAuth& obj_perms, - AuthRequest::Operation op) + AuthRequest::Operation op) const { if (static_cast(op) & 0x10LL) //No lockable object { @@ -449,7 +449,7 @@ bool AclManager::match_rules_wrapper( long long individual_obj_type, long long group_obj_type, long long cluster_obj_type, - const multimap &tmp_rules) + const multimap &tmp_rules) const { bool auth = false; @@ -525,7 +525,7 @@ bool AclManager::match_rules( long long resource_oid_mask, long long resource_gid_mask, long long resource_cid_mask, - const multimap &rules) + const multimap &rules) const { bool auth = false; diff --git a/src/host/HostShareNUMA.cc b/src/host/HostShareNUMA.cc index 07bde1a1c4..f23e9f4dd4 100644 --- a/src/host/HostShareNUMA.cc +++ b/src/host/HostShareNUMA.cc @@ -642,7 +642,7 @@ void HostShareNode::set_hugepage(unsigned long size, unsigned int nr, return; } - HugePage h = {size, nr, fr, usage}; + HugePage h = {size, nr, fr, usage, 0}; pages.insert(make_pair(h.size_kb, h)); @@ -1349,12 +1349,14 @@ void HostShareNUMA::del(HostShareCapacity &sr) if ( pt != mem_node.pages.end() ) { - pt->second.usage -= num_hp; - - if ( pt->second.usage < 0 ) + if ( pt->second.usage < num_hp ) { pt->second.usage = 0; } + else + { + pt->second.usage -= num_hp; + } mem_node.update_hugepages(); } diff --git a/src/monitor/include/Driver.h b/src/monitor/include/Driver.h index 9d07222336..1bb4f4dd7d 100644 --- a/src/monitor/include/Driver.h +++ b/src/monitor/include/Driver.h @@ -88,7 +88,7 @@ public: */ void write(const std::string& str) const { - ::write(to_drv, str.c_str(), str.size()); + (void) ::write(to_drv, str.c_str(), str.size()); }; /** diff --git a/src/rm/RequestManager.cc b/src/rm/RequestManager.cc index 8a8e598c29..73d1f07fb7 100644 --- a/src/rm/RequestManager.cc +++ b/src/rm/RequestManager.cc @@ -241,9 +241,11 @@ int RequestManager::setup_socket() int rc; int yes = 1; - struct addrinfo hints = {0}; + struct addrinfo hints; struct addrinfo * result; + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; diff --git a/src/scheduler/include/SchedulerPolicy.h b/src/scheduler/include/SchedulerPolicy.h index 1386b24714..acc98dad05 100644 --- a/src/scheduler/include/SchedulerPolicy.h +++ b/src/scheduler/include/SchedulerPolicy.h @@ -41,7 +41,7 @@ public: * @param obj, pointer to the object to schedule * */ - const void schedule(ObjectXML * obj) + void schedule(ObjectXML * obj) { vector priority; const vector resources = get_match_resources(obj); diff --git a/src/vnm/AddressRange.cc b/src/vnm/AddressRange.cc index fc29c8f511..227c787e87 100644 --- a/src/vnm/AddressRange.cc +++ b/src/vnm/AddressRange.cc @@ -1525,7 +1525,7 @@ int AddressRange::free_addr(PoolObjectSQL::ObjectType ot, int obid, unsigned int index = mac_i[0] - mac[0]; - if (index < 0 || index >= size) + if ( mac[0] > mac_i[0] || index >= size) { return -1; } @@ -1561,7 +1561,7 @@ int AddressRange::free_addr_by_ip(PoolObjectSQL::ObjectType ot, int obid, unsigned int index = ip_i - ip; - if (index < 0 || index >= size) + if (ip > ip_i || index >= size) { return -1; } @@ -1596,7 +1596,7 @@ int AddressRange::free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int obid, unsigned int index = ip_i[0] - ip6[0]; - if (index < 0 || index >= size || ip6[3] != ip_i[3] || ip6[2] != ip_i[2] + if (ip6[0] > ip_i[0] || index >= size || ip6[3] != ip_i[3] || ip6[2] != ip_i[2] || ip6[1] != ip_i[1]) { return -1; @@ -1663,7 +1663,7 @@ int AddressRange::free_addr_by_range(PoolObjectSQL::ObjectType ot, int obid, string error_msg; - if ((0 <= index) && (index < size)) + if ((mac[0] <= mac_i[0]) && (index < size)) { map::iterator it = allocated.find(index);