[asan] Revert r201402, r201404.
[blocksruntime.git] / lib / msan / lit_tests / ioctl_custom.cc
blob94ed528c70b910806c53034750d2a41c18cd5b8e
1 // RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %t
2 // RUN: %clangxx_msan -m64 -O3 -g %s -o %t && %t
4 // RUN: %clangxx_msan -DPOSITIVE -m64 -O0 -g %s -o %t && not %t 2>&1 | FileCheck %s
5 // RUN: %clangxx_msan -DPOSITIVE -m64 -O3 -g %s -o %t && not %t 2>&1 | FileCheck %s
7 #include <assert.h>
8 #include <stdlib.h>
9 #include <net/if.h>
10 #include <stdio.h>
11 #include <string.h>
12 #include <sys/ioctl.h>
13 #include <sys/socket.h>
14 #include <unistd.h>
16 int main(int argc, char **argv) {
17 int fd = socket(AF_INET, SOCK_STREAM, 0);
19 struct ifreq ifreqs[20];
20 struct ifconf ifc;
21 ifc.ifc_ifcu.ifcu_req = ifreqs;
22 #ifndef POSITIVE
23 ifc.ifc_len = sizeof(ifreqs);
24 #endif
25 int res = ioctl(fd, SIOCGIFCONF, (void *)&ifc);
26 // CHECK: UMR in ioctl{{.*}} at offset 0
27 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
28 // CHECK: #{{.*}} in main {{.*}}ioctl_custom.cc:[[@LINE-3]]
29 assert(res == 0);
30 for (int i = 0; i < ifc.ifc_len / sizeof(*ifc.ifc_ifcu.ifcu_req); ++i)
31 printf("%d %zu %s\n", i, strlen(ifreqs[i].ifr_name), ifreqs[i].ifr_name);
32 return 0;