diff options
author | Denis V. Lunev <den@openvz.org> | 2022-08-24 11:50:43 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2022-09-30 18:02:30 +0200 |
commit | b2aaf354773417f034fdc1a56cdb76ad79de6e19 (patch) | |
tree | e06c6496a8f93eb7787e517133b5be07b43ce284 /block | |
parent | 7f118b433a2e8c98fe5a8d73f0dd529aada327d1 (diff) |
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>
Diffstat (limited to 'block')
-rw-r--r-- | block/accounting.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/block/accounting.c b/block/accounting.c index 2030851d79..6b300c5129 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -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) |