Skip to content

Commit

Permalink
Silence false positive unaligned pointer access warning
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
twasilczyk committed Jan 10, 2019
1 parent 02b87eb commit f6e0796
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cangw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, ':');
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f6e0796

Please sign in to comment.