Avoid the potential negative left shift in test_xaccAccountType_Compatibility()

ACCT_TYPE_NONE is -1 but it should always be masked out by compat;
explicitly check for this instead of relying on that.

Add parenthesis to be clear that the default precedence is what's intended.
This commit is contained in:
Simon Arlott
2023-06-24 12:40:29 +01:00
parent d7b2b06bae
commit 069eb61a3f

View File

@@ -2587,7 +2587,7 @@ test_xaccAccountType_Compatibility (void)
else if (type == ACCT_TYPE_TRADING)
g_assert_cmpint (compat, == , trading_compat);
for (auto parent = ACCT_TYPE_NONE; parent < ACCT_TYPE_LAST; ++parent)
if (1 << parent & compat)
if (parent != ACCT_TYPE_NONE && (1 << parent) & compat)
g_assert (xaccAccountTypesCompatible (parent, type));
else
g_assert (!xaccAccountTypesCompatible (parent, type));