From: Dmitry V. Levin Date: Tue, 26 Jul 2016 15:59:28 +0000 (+0000) Subject: Fix one more code pattern that might break gcc strict aliasing rules X-Git-Tag: v4.13~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de5b0092a66394c28f62749ca2bf012d121ce128;p=strace Fix one more code pattern that might break gcc strict aliasing rules * btrfs.c (btrfs_ioctl): Add one more expicit cast to "void *", to avoid breaking strict-aliasing rules reported by some gcc compilers. * syscall.c (decode_socket_subcall): Likewise. * util.c (next_set_bit): Likewise. * tests/btrfs.c (btrfs_test_send_ioctl): Likewise. --- diff --git a/btrfs.c b/btrfs.c index b5d5d923..9c717684 100644 --- a/btrfs.c +++ b/btrfs.c @@ -808,7 +808,7 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl, sectorsize = args.sectorsize, clone_alignment = args.clone_alignment; #else - reserved32 = (__u32 *)args.reserved; + reserved32 = (__u32 *) (void *) args.reserved; nodesize = reserved32[0]; sectorsize = reserved32[1]; clone_alignment = reserved32[2]; diff --git a/syscall.c b/syscall.c index 2bf1554b..6af0dec0 100644 --- a/syscall.c +++ b/syscall.c @@ -586,7 +586,7 @@ decode_socket_subcall(struct tcb *tcp) unsigned int i; for (i = 0; i < nargs; ++i) tcp->u_arg[i] = (sizeof(uint32_t) == current_wordsize) - ? ((uint32_t *) buf)[i] : buf[i]; + ? ((uint32_t *) (void *) buf)[i] : buf[i]; } #endif diff --git a/tests/btrfs.c b/tests/btrfs.c index 9a4ee443..e5940cea 100644 --- a/tests/btrfs.c +++ b/tests/btrfs.c @@ -1353,7 +1353,7 @@ btrfs_test_send_ioctl(void) printf("}) = -1 EBADF (%m)\n"); args.clone_sources_count = 2; - args.clone_sources = (__u64 *)u64_array; + args.clone_sources = (__u64 *) (void *) u64_array; printf("ioctl(-1, BTRFS_IOC_SEND, " "{send_fd=%d, clone_sources_count=%" PRI__u64 diff --git a/util.c b/util.c index 3979cab9..afa32903 100644 --- a/util.c +++ b/util.c @@ -171,7 +171,7 @@ int next_set_bit(const void *bit_array, unsigned cur_bit, unsigned size_bits) { const unsigned endian = 1; - int little_endian = *(char*)&endian; + int little_endian = * (char *) (void *) &endian; const uint8_t *array = bit_array; unsigned pos = cur_bit / 8;