Home | History | Annotate | Download | only in tests
      1 #include <sys/socket.h>
      2 #include <stdlib.h>
      3 #include <stdio.h>
      4 
      5 int main(void)
      6 {
      7    struct sockaddr name;
      8    int res1, res2, res3;
      9    unsigned len = 10;
     10 
     11    res1 = socket(PF_UNIX, SOCK_STREAM, 0);
     12    if (res1 == 0) {
     13       fprintf(stderr, "socket() failed\n");
     14       exit(1);
     15    }
     16 
     17    /* Valgrind 1.0.X doesn't report the second error */
     18    res2 = getsockname(res1, NULL,  &len);    /* NULL is bogus */
     19    res3 = getsockname(res1, &name, NULL);    /* NULL is bogus */
     20    if (res2 == -1) {
     21       fprintf(stderr, "getsockname(1) failed\n");
     22    }
     23    if (res3 == -1) {
     24       fprintf(stderr, "getsockname(2) failed\n");
     25    }
     26 
     27    return 0;
     28 }
     29 
     30