30 lines · cpp
1// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t2// RUN: %clangxx_msan -O3 -g %s -o %t && %run %t3 4#include <assert.h>5#include <fcntl.h>6#include <sound/asound.h>7#include <stdio.h>8#include <stdlib.h>9#include <sys/ioctl.h>10#include <sys/socket.h>11#include <unistd.h>12 13#include <sanitizer/msan_interface.h>14 15int main(int argc, char **argv) {16 int fd = open("/dev/snd/controlC0", O_RDONLY);17 if (fd < 0) {18 printf("Unable to open sound device.");19 return 0;20 }21 const unsigned sz = sizeof(snd_ctl_card_info);22 void *info = malloc(sz + 1);23 assert(__msan_test_shadow(info, sz) == 0);24 assert(ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, info) >= 0);25 assert(__msan_test_shadow(info, sz + 1) == sz);26 close(fd);27 free(info);28 return 0;29}30