[PATCH u-boot v2019.04-aspeed-openbmc] otp: Reduce size of struct otpkey

Zev Weiss zweiss at equinix.com
Sat Jul 16 19:08:47 AEST 2022


On Thu, Jul 14, 2022 at 12:45:52AM PDT, Joel Stanley wrote:
>Don't store more information than is used.
>
>  Function                                     old     new   delta
>  _otp_print_key                               540     580     +40
>  otp_verify_boot_image                       1336    1328      -8
>  a2_key_type                                  640      40    -600
>  a1_key_type                                  640      40    -600
>  a3_key_type                                 1024      64    -960
>  a0_key_type                                 1024      64    -960
>  Total: Before=279318, After=276230, chg -1.11%
>
>Signed-off-by: Joel Stanley <joel at jms.id.au>
>---
> cmd/otp.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/cmd/otp.c b/cmd/otp.c
>index 049c217d6048..6dd2d2bdfb17 100644
>--- a/cmd/otp.c
>+++ b/cmd/otp.c
>@@ -133,11 +133,11 @@ struct otpstrap_status {
> };
>
> struct otpkey_type {
>-	int value;
>-	int key_type;
>-	int order;
>-	int need_id;
>-	char information[110];
>+	int value: 4;
>+	int key_type: 4;
>+	int order: 1;
>+	int need_id: 1;

I'm not sure if there's any chance it could lead to any actual problems
here, but I think some static analyzers get unhappy about single-bit
signed bitfields...perhaps these (maybe all four?) should be unsigned
instead?

>+	char *information;
> };
>
> struct otp_pro_sts {
>-- 
>2.35.1
>


More information about the openbmc mailing list