1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

M #-: Fix compilation warnings

This commit is contained in:
Ruben S. Montero 2020-09-05 19:29:49 +02:00
parent aa379a100e
commit 7e687b9a58
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
9 changed files with 45 additions and 31 deletions

View File

@ -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<int>& user_groups,
const PoolObjectAuth& obj_perms,
AuthRequest::Operation op);
bool authorize(int uid,
const set<int>& 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<long long, AclRule*>& rules);
const multimap<long long, AclRule*>& 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<long long, AclRule*> &tmp_rules);
const multimap<long long, AclRule*> &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<pthread_mutex_t *>(&mutex));
};
/**
* Function to unlock the manager
*/
void unlock()
void unlock() const
{
pthread_mutex_unlock(&mutex);
pthread_mutex_unlock(const_cast<pthread_mutex_t *>(&mutex));
};
// -------------------------------------------------------------------------

View File

@ -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;
};

View File

@ -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);

View File

@ -217,11 +217,11 @@ AclManager::~AclManager()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
const bool AclManager::authorize(
bool AclManager::authorize(
int uid,
const set<int>& 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<long long int>(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<long long, AclRule*> &tmp_rules)
const multimap<long long, AclRule*> &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<long long, AclRule*> &rules)
const multimap<long long, AclRule*> &rules) const
{
bool auth = false;

View File

@ -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();
}

View File

@ -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());
};
/**

View File

@ -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;

View File

@ -41,7 +41,7 @@ public:
* @param obj, pointer to the object to schedule
*
*/
const void schedule(ObjectXML * obj)
void schedule(ObjectXML * obj)
{
vector<float> priority;
const vector<Resource *> resources = get_match_resources(obj);

View File

@ -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<unsigned int, long long>::iterator it = allocated.find(index);