block: pass OnOffAuto instead of bool to block_acct_setup()

We would have one more place for block_acct_setup() calling, which should
not corrupt original value.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
CC: Peter Krempa <pkrempa@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220824095044.166009-2-den@openvz.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Denis V. Lunev
2022-08-24 11:50:43 +02:00
committed by Kevin Wolf
parent 7f118b433a
commit b2aaf35477
3 changed files with 35 additions and 10 deletions
+18 -4
View File
@@ -40,11 +40,25 @@ void block_acct_init(BlockAcctStats *stats)
}
}
void block_acct_setup(BlockAcctStats *stats, bool account_invalid,
bool account_failed)
static bool bool_from_onoffauto(OnOffAuto val, bool def)
{
stats->account_invalid = account_invalid;
stats->account_failed = account_failed;
switch (val) {
case ON_OFF_AUTO_AUTO:
return def;
case ON_OFF_AUTO_ON:
return true;
case ON_OFF_AUTO_OFF:
return false;
default:
abort();
}
}
void block_acct_setup(BlockAcctStats *stats, enum OnOffAuto account_invalid,
enum OnOffAuto account_failed)
{
stats->account_invalid = bool_from_onoffauto(account_invalid, true);
stats->account_failed = bool_from_onoffauto(account_failed, true);
}
void block_acct_cleanup(BlockAcctStats *stats)