From d5b947ffe60501c55cbcc59b247a4b8e6c944fa6 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Mon, 19 Apr 2021 14:33:34 +0300 Subject: [PATCH] Driver: Simplify fort_conf_app_blocked(). --- src/driver/common/fortconf.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/driver/common/fortconf.c b/src/driver/common/fortconf.c index 00bb8b88..0b022d5b 100644 --- a/src/driver/common/fortconf.c +++ b/src/driver/common/fortconf.c @@ -267,16 +267,14 @@ FORT_API BOOL fort_conf_app_blocked( const UINT32 app_perm = app_perm_val << (app_flags.group_index * 2); /* Block All */ - if (conf->flags.app_block_all) { - /* Block, if it is not explicitly allowed */ - return !app_found || (app_perm & conf->app_perms_allow_mask) == 0; - } + const BOOL app_allowed = app_found && (app_perm & conf->app_perms_allow_mask) != 0; + if (conf->flags.app_block_all) + return !app_allowed; /* Block, if it is not explicitly allowed */ /* Allow All */ - if (conf->flags.app_allow_all) { - /* Block, if it is explicitly blocked */ - return app_found && (app_perm & conf->app_perms_block_mask) != 0; - } + const BOOL app_blocked = app_found && (app_perm & conf->app_perms_block_mask) != 0; + if (conf->flags.app_allow_all) + return app_blocked; /* Block, if it is explicitly blocked */ /* Block or Allow */ if (!app_found) { @@ -285,8 +283,7 @@ FORT_API BOOL fort_conf_app_blocked( } /* Block, if it is explicitly blocked and not allowed */ - return (app_perm & conf->app_perms_block_mask) != 0 - && (app_perm & conf->app_perms_allow_mask) == 0; + return app_blocked && !app_allowed; } FORT_API UINT16 fort_conf_app_period_bits(const PFORT_CONF conf, FORT_TIME time, int *periods_n)