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