summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2022-07-15 14:40:30 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-04 22:35:20 +0000
commit439eed13cda46acca42fd3dfb081a3bff29a8b73 (patch)
tree4f8070e4731670c7f3cebd781dad1fbf671c5e63
parent0096058366ada3cfbaf8aa3c1ffcca99d984f263 (diff)
downloadchrome-ec-439eed13cda46acca42fd3dfb081a3bff29a8b73.tar.gz
ec_commands: support C++ for rand_num
Update the struct edc_response_rand_num to have a size 1 which will allow it to compile with C++. As documented, this will work because any request using ec_params_rand_num::num_rand_bytes should always set to at least 1. BRANCH=none BUG=none TEST=zmake testall Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I06d2a4032033797f9858aecc4c45e858d8f19339 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3765454 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--include/ec_commands.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 27a3ca1bd5..ad8a8d75f3 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1921,10 +1921,19 @@ struct ec_params_rand_num {
} __ec_align4;
struct ec_response_rand_num {
- uint8_t rand[0]; /**< generated random numbers */
-} __ec_align4;
+ /**
+ * generated random numbers in the range of 1 to EC_MAX_INSIZE. The size
+ * of this is set to 1 in order to support C++ compilation. The true
+ * size of rand is determined by ec_params_rand_num's num_rand_bytes.
+ */
+ uint8_t rand[1];
+} __ec_align1;
-BUILD_ASSERT(sizeof(struct ec_response_rand_num) == 0);
+/* C++ requires all structs to be at least 1 byte long. Since struct
+ * ec_response_rand_num will never be used with num_rand_bytes == 0 (from
+ * ec_params_rand_num) it is set to always be at least 1.
+ */
+BUILD_ASSERT(sizeof(struct ec_response_rand_num) == 1);
/**
* Get information about the key used to sign the RW firmware.