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 <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
This commit is contained in:
Manoj Gupta
2016-11-14 11:27:29 -08:00
committed by chrome-bot
parent 173d77a63d
commit b2bc234197

View File

@@ -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 <dev_id> <port> <filename>\n",