Kernel: Make sure MSB is not set on SMO keys
This commit is contained in:
parent
a1b3490764
commit
6840a8983c
|
@ -14,7 +14,7 @@ namespace Kernel
|
|||
class SharedMemoryObjectManager
|
||||
{
|
||||
public:
|
||||
using Key = uint32_t;
|
||||
using Key = size_t;
|
||||
|
||||
public:
|
||||
static BAN::ErrorOr<void> initialize();
|
||||
|
|
|
@ -32,9 +32,12 @@ namespace Kernel
|
|||
|
||||
LockGuard _(m_mutex);
|
||||
|
||||
Key key = Random::get<Key>();
|
||||
// NOTE: don't set the top bit so cast to signed is not negative
|
||||
auto generate_key = []() { return Random::get<Key>() & (~(Key)0 >> 1); };
|
||||
|
||||
Key key = generate_key();
|
||||
while (m_objects.contains(key))
|
||||
key = Random::get<Key>();
|
||||
key = generate_key();
|
||||
|
||||
TRY(m_objects.insert(key, object));
|
||||
return key;
|
||||
|
|
Loading…
Reference in New Issue