|
|
b9d646 |
From 0bf42a4489973005ddd912a800dfb92eff2806e8 Mon Sep 17 00:00:00 2001
|
|
|
b9d646 |
From: William Roberts <william.c.roberts@intel.com>
|
|
|
b9d646 |
Date: Mon, 16 Sep 2019 17:12:23 -0700
|
|
|
b9d646 |
Subject: [PATCH] esys_iutil: use memcmp in byte array comparison
|
|
|
b9d646 |
|
|
|
b9d646 |
Rather than a byte for byte forloop, use memcmp() so the compiler can
|
|
|
b9d646 |
use architectural optimizations.
|
|
|
b9d646 |
|
|
|
b9d646 |
Signed-off-by: William Roberts <william.c.roberts@intel.com>
|
|
|
b9d646 |
---
|
|
|
b9d646 |
src/tss2-esys/esys_iutil.c | 27 +++++----------------------
|
|
|
b9d646 |
1 file changed, 5 insertions(+), 22 deletions(-)
|
|
|
b9d646 |
|
|
|
b9d646 |
diff --git a/src/tss2-esys/esys_iutil.c b/src/tss2-esys/esys_iutil.c
|
|
|
b9d646 |
index 94d0332c5b7d..08a9b7dffcbd 100644
|
|
|
b9d646 |
--- a/src/tss2-esys/esys_iutil.c
|
|
|
b9d646 |
+++ b/src/tss2-esys/esys_iutil.c
|
|
|
b9d646 |
@@ -35,23 +35,6 @@ cmp_UINT16(const UINT16 * in1, const UINT16 * in2)
|
|
|
b9d646 |
}
|
|
|
b9d646 |
}
|
|
|
b9d646 |
|
|
|
b9d646 |
-/**
|
|
|
b9d646 |
- * Compare variables of type BYTE.
|
|
|
b9d646 |
- * @param[in] in1 Variable to be compared with:
|
|
|
b9d646 |
- * @param[in] in2
|
|
|
b9d646 |
- */
|
|
|
b9d646 |
-static bool
|
|
|
b9d646 |
-cmp_BYTE(const BYTE * in1, const BYTE * in2)
|
|
|
b9d646 |
-{
|
|
|
b9d646 |
- LOG_TRACE("call");
|
|
|
b9d646 |
- if (*in1 == *in2)
|
|
|
b9d646 |
- return true;
|
|
|
b9d646 |
- else {
|
|
|
b9d646 |
- LOG_TRACE("cmp false");
|
|
|
b9d646 |
- return false;
|
|
|
b9d646 |
- }
|
|
|
b9d646 |
-}
|
|
|
b9d646 |
-
|
|
|
b9d646 |
/**
|
|
|
b9d646 |
* Compare two arrays of type BYTE.
|
|
|
b9d646 |
* @param[in] in1 array to be compared with:.
|
|
|
b9d646 |
@@ -65,12 +48,12 @@ cmp_BYTE_array(const BYTE * in1, size_t count1, const BYTE * in2, size_t count2)
|
|
|
b9d646 |
LOG_TRACE("cmp false");
|
|
|
b9d646 |
return false;
|
|
|
b9d646 |
}
|
|
|
b9d646 |
- for (size_t i = 0; i < count1; i++) {
|
|
|
b9d646 |
- if (!cmp_BYTE(&in1[i], &in2[i])) {
|
|
|
b9d646 |
- LOG_TRACE("cmp false");
|
|
|
b9d646 |
- return false;
|
|
|
b9d646 |
- }
|
|
|
b9d646 |
+
|
|
|
b9d646 |
+ if (memcmp(in1, in2, count2) != 0) {
|
|
|
b9d646 |
+ LOG_TRACE("cmp false");
|
|
|
b9d646 |
+ return false;
|
|
|
b9d646 |
}
|
|
|
b9d646 |
+
|
|
|
b9d646 |
return true;
|
|
|
b9d646 |
}
|
|
|
b9d646 |
|
|
|
b9d646 |
--
|
|
|
b9d646 |
2.27.0
|
|
|
b9d646 |
|