mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
p2p: allow NetPermissions::ClearFlag() only with PF_ISIMPLICIT
NetPermissions::ClearFlag() is currently only called in the codebase with an `f` value of NetPermissionFlags::PF_ISIMPLICIT. If that should change in the future, ClearFlag() should not be called with `f` being a subflag of a multiflag, e.g. NetPermissionFlags::PF_RELAY or NetPermissionFlags::PF_DOWNLOAD, as that would leave `flags` in an invalid state corresponding to none of the existing NetPermissionFlags. Therefore, allow only calling ClearFlag with the implicit flag for now. Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This commit is contained in:
@@ -51,8 +51,14 @@ public:
|
||||
{
|
||||
flags = static_cast<NetPermissionFlags>(flags | f);
|
||||
}
|
||||
//! ClearFlag is only called with `f` == NetPermissionFlags::PF_ISIMPLICIT.
|
||||
//! If that should change in the future, be aware that ClearFlag should not
|
||||
//! be called with a subflag of a multiflag, e.g. NetPermissionFlags::PF_RELAY
|
||||
//! or NetPermissionFlags::PF_DOWNLOAD, as that would leave `flags` in an
|
||||
//! invalid state corresponding to none of the existing flags.
|
||||
static inline void ClearFlag(NetPermissionFlags& flags, NetPermissionFlags f)
|
||||
{
|
||||
assert(f == NetPermissionFlags::PF_ISIMPLICIT);
|
||||
flags = static_cast<NetPermissionFlags>(flags & ~f);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user