From b2bc2341978884cf0bde01c1b9de06ea0c092576 Mon Sep 17 00:00:00 2001 From: Manoj Gupta Date: Mon, 14 Nov 2016 11:27:29 -0800 Subject: [PATCH] Fix EC build for latest llvm BRANCH=none util/ectool.c:1158 merror: taking address of packed member 'size' of class or structure 'ec_params_usb_pd_fw_update' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] For this case, the pointer is always aligned but clang complains. Workaround using double pointer casts to char and uint. uint32_t *data = &(p->size) + 1; BUG=chromium:665240 TEST=Builds now Change-Id: Ibccf0f6e409b9724fc9e5acf28dde570e9d341e3 Reviewed-on: https://chromium-review.googlesource.com/411384 Commit-Ready: Manoj Gupta Tested-by: Manoj Gupta Reviewed-by: Yunlian Jiang --- util/ectool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/ectool.c b/util/ectool.c index 3ba5804095..07510c529b 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -1155,7 +1155,11 @@ int cmd_flash_pd(int argc, char *argv[]) int rv, fsize, step = 96; char *e; char *buf; - uint32_t *data = &(p->size) + 1; + /* Double casting is a workaround to silent clang error. + * The pointer is always aligned but clang complains. + * https://crbug.com/665240 + */ + uint32_t *data = (uint32_t *) ((char *)&(p->size)) + 1; if (argc < 4) { fprintf(stderr, "Usage: %s \n",