Fixed another issue
This commit is contained in:
parent
7fbb560775
commit
cb73d9df32
20
src/Error.h
20
src/Error.h
@ -8,6 +8,8 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#define _NDEBUG
|
||||
|
||||
namespace ts {
|
||||
namespace permission {
|
||||
enum PermissionType : uint16_t;
|
||||
@ -174,7 +176,7 @@ namespace ts {
|
||||
* bits [64 - sizeof(error::type);64] => error type | Usually evaluates to [48;64]
|
||||
* bits [64 - sizeof(error::type) - sizeof(permission::PermissionType);64 - sizeof(error::type)] => permission id | Usually evaluates to [32;48]
|
||||
*/
|
||||
uint64_t data;
|
||||
uint64_t data = 0;
|
||||
|
||||
/* Test for mode 1 as described before */
|
||||
static_assert(sizeof(permission::PermissionType) * 8 + sizeof(error::type) * 8 <= 63);
|
||||
@ -192,7 +194,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
inline bool is_detailed() {
|
||||
return (this->data & 0x1) == 0;
|
||||
return (this->data & 0x1UL) == 0;
|
||||
}
|
||||
|
||||
inline detailed_command_result* release_details() {
|
||||
@ -201,7 +203,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG /* We dont need to secure that because gcc deduct us to an uint64_t and the only advantage is the mem leak test which is deactivated anyways */
|
||||
#ifndef _NDEBUG /* We dont need to secure that because gcc deduct us to an uint64_t and the only advantage is the mem leak test which is deactivated anyways */
|
||||
command_result(command_result&) = delete;
|
||||
command_result(const command_result&) = delete;
|
||||
command_result(command_result&& other) : data(other.data) {
|
||||
@ -209,9 +211,7 @@ namespace ts {
|
||||
}
|
||||
#endif
|
||||
|
||||
command_result() {
|
||||
this->data = 0;
|
||||
}
|
||||
command_result() = default;
|
||||
|
||||
explicit command_result(permission::PermissionType permission) {
|
||||
this->data = 0x01; /* the the type to 1 */
|
||||
@ -237,7 +237,7 @@ namespace ts {
|
||||
details_ptr->extra_properties["extra_msg"] = message;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef _NDEBUG
|
||||
/* if we're not using any debug we dont have to use a deconstructor. A deconstructor prevent a direct uint64_t return as described above */
|
||||
~command_result() {
|
||||
if((this->data & 0x01) == 0x00) {
|
||||
@ -246,8 +246,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
static_assert(sizeof(command_result) == 8);
|
||||
|
||||
struct ErrorType {
|
||||
public:
|
||||
@ -330,4 +330,6 @@ namespace ts {
|
||||
public:
|
||||
CommandResultPermissionError(permission::PermissionType error, const std::string &extraMsg = "");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#undef _NDEBUG
|
@ -1269,7 +1269,6 @@ void v2::PermissionManager::set_channel_permission(const PermissionType &permiss
|
||||
} else if(action_value == v2::PermissionUpdateType::delete_value) {
|
||||
permission_container->flags.value_set = false;
|
||||
permission_container->flags.flag_value_update = true;
|
||||
permission_container->values.value = permNotGranted; /* required for the database else it does not "deletes" the value */
|
||||
}
|
||||
|
||||
if(action_grant == v2::PermissionUpdateType::set_value) {
|
||||
@ -1279,7 +1278,6 @@ void v2::PermissionManager::set_channel_permission(const PermissionType &permiss
|
||||
} else if(action_grant == v2::PermissionUpdateType::delete_value) {
|
||||
permission_container->flags.grant_set = false;
|
||||
permission_container->flags.flag_grant_update = true;
|
||||
permission_container->values.grant = permNotGranted; /* required for the database else it does not "deletes" the value */
|
||||
}
|
||||
|
||||
if(flag_skip >= 0) {
|
||||
@ -1395,18 +1393,19 @@ const std::vector<v2::PermissionDBUpdateEntry> v2::PermissionManager::flush_db_u
|
||||
/* we only need an update it the permission has a DB reference or we will set the permission */
|
||||
if(permission.flags.database_reference || permission.flags.permission_set()) {
|
||||
/*
|
||||
PermissionType permission;
|
||||
ChannelId channel_id;
|
||||
PermissionType permission;
|
||||
ChannelId channel_id;
|
||||
|
||||
PermissionValues values;
|
||||
PermissionUpdateType update_value;
|
||||
PermissionUpdateType update_grant;
|
||||
PermissionValues values;
|
||||
PermissionUpdateType update_value;
|
||||
PermissionUpdateType update_grant;
|
||||
|
||||
bool flag_new: 1;
|
||||
bool flag_db: 1;
|
||||
bool flag_delete: 1;
|
||||
bool flag_skip: 1;
|
||||
bool flag_negate: 1;
|
||||
*/
|
||||
result.push_back(v2::PermissionDBUpdateEntry{
|
||||
auto& entry = result.emplace_back(v2::PermissionDBUpdateEntry{
|
||||
(PermissionType) (block_index * PERMISSIONS_BULK_ENTRY_COUNT + permission_index),
|
||||
(ChannelId) 0,
|
||||
|
||||
@ -1419,6 +1418,14 @@ const std::vector<v2::PermissionDBUpdateEntry> v2::PermissionManager::flush_db_u
|
||||
(bool) permission.flags.skip,
|
||||
(bool) permission.flags.negate
|
||||
});
|
||||
|
||||
/* required for the database */
|
||||
if(!permission.flags.value_set)
|
||||
entry.values.value = permNotGranted;
|
||||
|
||||
if(!permission.flags.grant_set)
|
||||
entry.values.grant = permNotGranted;
|
||||
|
||||
permission.flags.database_reference = permission.flags.permission_set();
|
||||
}
|
||||
|
||||
@ -1437,21 +1444,28 @@ const std::vector<v2::PermissionDBUpdateEntry> v2::PermissionManager::flush_db_u
|
||||
|
||||
/* we only need an update it the permission has a DB reference or we will set the permission */
|
||||
if(permission->flags.database_reference || permission->flags.permission_set()) {
|
||||
result.push_back(
|
||||
v2::PermissionDBUpdateEntry{
|
||||
permission->permission,
|
||||
permission->channel_id,
|
||||
|
||||
permission->values,
|
||||
permission->flags.flag_value_update ? (permission->flags.value_set ? PermissionUpdateType::set_value : PermissionUpdateType::delete_value) : PermissionUpdateType::do_nothing,
|
||||
permission->flags.flag_grant_update ? (permission->flags.grant_set ? PermissionUpdateType::set_value : PermissionUpdateType::delete_value) : PermissionUpdateType::do_nothing,
|
||||
auto& entry = result.emplace_back(v2::PermissionDBUpdateEntry{
|
||||
permission->permission,
|
||||
permission->channel_id,
|
||||
|
||||
permission->values,
|
||||
(PermissionUpdateType) (permission->flags.flag_value_update ? (permission->flags.value_set ? PermissionUpdateType::set_value : PermissionUpdateType::delete_value) : PermissionUpdateType::do_nothing),
|
||||
(PermissionUpdateType) (permission->flags.flag_grant_update ? (permission->flags.grant_set ? PermissionUpdateType::set_value : PermissionUpdateType::delete_value) : PermissionUpdateType::do_nothing),
|
||||
|
||||
(bool) permission->flags.database_reference,
|
||||
(bool) !permission->flags.permission_set(), /* db delete */
|
||||
(bool) permission->flags.skip,
|
||||
(bool) permission->flags.negate
|
||||
});
|
||||
|
||||
/* required for the database */
|
||||
if(!permission->flags.value_set)
|
||||
entry.values.value = permNotGranted;
|
||||
|
||||
if(!permission->flags.grant_set)
|
||||
entry.values.grant = permNotGranted;
|
||||
|
||||
(bool) permission->flags.database_reference,
|
||||
(bool) !permission->flags.permission_set(), /* db delete */
|
||||
(bool) permission->flags.skip,
|
||||
(bool) permission->flags.negate
|
||||
}
|
||||
);
|
||||
permission->flags.database_reference = permission->flags.permission_set();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user