From: Dmitry Kasatkin Date: Fri, 22 Aug 2014 06:43:55 +0000 (+0300) Subject: ima: simplify conditional statement to improve performance X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f68c05f4d2d4e19c40f4ac1e769cc0a2f9f544a0;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git ima: simplify conditional statement to improve performance Precede bit testing before string comparison makes code faster. Also refactor statement as a single line pointer assignment. Logic is following: we set 'xattr_ptr' to read xattr value when we will do appraisal or in any case when measurement template is other than 'ima'. Signed-off-by: Dmitry Kasatkin Signed-off-by: Mimi Zohar --- diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index f82cf9b8e92b..f7b85bf0eaf3 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -206,10 +206,8 @@ static int process_measurement(struct file *file, const char *filename, } template_desc = ima_template_desc_current(); - if (strcmp(template_desc->name, IMA_TEMPLATE_IMA_NAME) == 0) { - if (action & IMA_APPRAISE_SUBMASK) - xattr_ptr = &xattr_value; - } else + if ((action & IMA_APPRAISE_SUBMASK) || + strcmp(template_desc->name, IMA_TEMPLATE_IMA_NAME) != 0) xattr_ptr = &xattr_value; rc = ima_collect_measurement(iint, file, xattr_ptr, &xattr_len);