From f6e07960d3feba621302d7ef32012d8346e90b67 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Thu, 10 Jan 2019 08:09:10 -0800 Subject: [PATCH] Silence false positive unaligned pointer access warning This is a warning coming up on Android (ARM) platform. Clang 4.x creates a false positive here: the can_id is the first (and aligned) value in the packed struct modattr, so it's always aligned if the struct itself is aligned. --- cangw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cangw.c b/cangw.c index ff76fd7..14b06b4 100644 --- a/cangw.c +++ b/cangw.c @@ -282,6 +282,7 @@ int parse_mod(char *optarg, struct modattr *modmsg) { char *ptr, *nptr; char hexdata[17] = {0}; + canid_t can_id; ptr = optarg; nptr = strchr(ptr, ':'); @@ -330,9 +331,10 @@ int parse_mod(char *optarg, struct modattr *modmsg) ptr++; } - if (sscanf(++ptr, "%x.%hhx.%16s", &modmsg->cf.can_id, + if (sscanf(++ptr, "%x.%hhx.%16s", &can_id, (unsigned char *)&modmsg->cf.can_dlc, hexdata) != 3) return 5; + modmsg->cf.can_id = can_id; /* 4-bit masks can have values from 0 to 0xF */ if (modmsg->cf.can_dlc > 0xF)