]> granicus.if.org Git - strace/commitdiff
Fix one more code pattern that might break gcc strict aliasing rules
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 26 Jul 2016 15:59:28 +0000 (15:59 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 26 Jul 2016 16:14:50 +0000 (16:14 +0000)
* 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.

btrfs.c
syscall.c
tests/btrfs.c
util.c

diff --git a/btrfs.c b/btrfs.c
index b5d5d9231a5d59fc5db57ea965453979ac0b0706..9c717684d3e3a68dc872f3e664436397989203a3 100644 (file)
--- 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];
index 2bf1554b73c85677252a97fbbd48758440a68443..6af0dec028dc706162d119aec9f0fb6c9b30a382 100644 (file)
--- 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
 
index 9a4ee443023b060b356035b046abc61cf6cb0660..e5940ceaaffd13ce95253a734ef6ea54902e63b3 100644 (file)
@@ -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 3979cab9747c2a181ecff7475fe9ab23719e78d5..afa32903b71a6fda6db2169ab264626f7df335f0 100644 (file)
--- 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;