24 lines · cpp
1// RUN: %clangxx_msan -O0 %s -o %t && %run %t 2>&12// RUN: %clangxx_msan -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %run %t 2>&13// RUN: %clangxx_msan -O3 %s -o %t && %run %t 2>&14 5#include <assert.h>6#include <errno.h>7#include <net/if.h>8#include <stdio.h>9#include <string.h>10 11#include <sanitizer/msan_interface.h>12 13int main(int argc, char *argv[]) {14 char ifname[IF_NAMESIZE + 1];15 assert(0 == __msan_test_shadow(ifname, sizeof(ifname)));16 if (!if_indextoname(1, ifname)) {17 assert(errno == ENXIO);18 printf("No network interfaces found.\n");19 return 0;20 }21 assert(strlen(ifname) + 1 <= __msan_test_shadow(ifname, sizeof(ifname)));22 return 0;23}24