Avoid taking the address of a packed struct member in mfiutil

Fix a clang 4.0.0 warning about taking the address of a packed member of
struct mfi_evt in mfiutil:

    usr.sbin/mfiutil/mfi_evt.c:583:30: error: taking address of packed
    member 'members' of class or structure 'mfi_evt' may result in an
    unaligned pointer value [-Werror,-Waddress-of-packed-member]
                            if (parse_locale(optarg, &filter.members.locale) < 0) {
                                                      ^~~~~~~~~~~~~~~~~~~~~

Use a local variable instead, and copy that into the struct.

Reviewed by:	jhb
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D9069
This commit is contained in:
Dimitry Andric 2017-01-09 19:39:35 +00:00
parent 0219a00679
commit 3ac0e4769e

View File

@ -540,6 +540,7 @@ show_events(int ac, char **av)
char *cp; char *cp;
ssize_t size; ssize_t size;
uint32_t seq, start, stop; uint32_t seq, start, stop;
uint16_t locale;
uint8_t status; uint8_t status;
int ch, error, fd, num_events, verbose; int ch, error, fd, num_events, verbose;
u_int i; u_int i;
@ -580,12 +581,13 @@ show_events(int ac, char **av)
} }
break; break;
case 'l': case 'l':
if (parse_locale(optarg, &filter.members.locale) < 0) { if (parse_locale(optarg, &locale) < 0) {
error = errno; error = errno;
warn("Error parsing event locale"); warn("Error parsing event locale");
close(fd); close(fd);
return (error); return (error);
} }
filter.members.locale = locale;
break; break;
case 'n': case 'n':
val = strtol(optarg, &cp, 0); val = strtol(optarg, &cp, 0);