| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O -Wuninitialized" } */ |
| 3 |
|
| 4 |
struct hostent { |
| 5 |
char **h_addr_list; |
| 6 |
}; |
| 7 |
struct hostent *gethostbyname(const char*); |
| 8 |
int socket(void); |
| 9 |
int close(int); |
| 10 |
int connect(int, const char*); |
| 11 |
|
| 12 |
int get_tcp_socket(const char *machine) |
| 13 |
{ |
| 14 |
struct hostent *hp; |
| 15 |
int s42, x; |
| 16 |
char **addr; |
| 17 |
|
| 18 |
hp = gethostbyname(machine); |
| 19 |
x = 0; |
| 20 |
for (addr = hp->h_addr_list; *addr; addr++) |
| 21 |
{ |
| 22 |
s42 = socket(); |
| 23 |
if (s42 < 0) |
| 24 |
return -1; |
| 25 |
x = connect(s42, *addr); |
| 26 |
if (x == 0) |
| 27 |
break; |
| 28 |
close(s42); |
| 29 |
} |
| 30 |
if (x < 0) |
| 31 |
return -1; |
| 32 |
return s42; /* { dg-warning "uninitialized" } */ |
| 33 |
} |