ima: simplify conditional statement to improve performance
authorDmitry Kasatkin <d.kasatkin@samsung.com>
Fri, 22 Aug 2014 06:43:55 +0000 (09:43 +0300)
committerMimi Zohar <zohar@linux.vnet.ibm.com>
Tue, 9 Sep 2014 14:28:47 +0000 (10:28 -0400)
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 <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
security/integrity/ima/ima_main.c

index f82cf9b8e92bebeab506aa6dd19906d297e64e4f..f7b85bf0eaf3ad6081f7b309ac7c3842375eb848 100644 (file)
@@ -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);