Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / ioctl_custom.cpp
blobe0abf669971e85cabd26d5f4f1c73d27cbf9307d
1 // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
2 // RUN: %clangxx_msan -O3 -g %s -o %t && %run %t
4 // RUN: %clangxx_msan -DPOSITIVE -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
5 // RUN: %clangxx_msan -DPOSITIVE -O3 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
7 // Reports different report (not analyzed)
8 // XFAIL: target={{.*netbsd.*}}
10 #include <assert.h>
11 #include <stdlib.h>
12 #include <net/if.h>
13 #include <stdio.h>
14 #include <string.h>
15 #include <sys/ioctl.h>
16 #include <sys/socket.h>
17 #include <unistd.h>
19 int main(int argc, char **argv) {
20 int fd = socket(AF_UNIX, SOCK_STREAM, 0);
22 struct ifreq ifreqs[20];
23 struct ifconf ifc;
24 ifc.ifc_ifcu.ifcu_req = ifreqs;
25 #ifndef POSITIVE
26 ifc.ifc_len = sizeof(ifreqs);
27 #endif
28 int res = ioctl(fd, SIOCGIFCONF, (void *)&ifc);
29 // CHECK: Uninitialized bytes in ioctl{{.*}} at offset 0 inside [0x{{.*}}, 4)
30 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
31 // CHECK: #{{.*}} in main {{.*}}ioctl_custom.cpp:[[@LINE-3]]
32 assert(res == 0);
33 for (int i = 0; i < ifc.ifc_len / sizeof(*ifc.ifc_ifcu.ifcu_req); ++i)
34 printf("%d %zu %s\n", i, strlen(ifreqs[i].ifr_name), ifreqs[i].ifr_name);
35 return 0;