fix use of partly initialized struct in tcp test

Properly initialize sockaddr 'name' used by tcp test, and remove
a redundant re-declaration of this variable in a nested scope.

Change-Id: Id6e488308a72be96cca6aa661f088d2c3c67a6a3
Related: CID#188848
changes/54/11854/1
Stefan Sperling 4 years ago
parent cf9e5f8c33
commit 3cf5229fa0
  1. 3
      test_apps/tcp.c

@ -69,7 +69,7 @@ int do_tcp_connect( xmlNodePtr p, int *s )
/* bind to a local addr */
if (strlen(local_src) != 0) {
struct sockaddr_in name;
memset(&name, 0, sizeof(name));
name.sin_family = AF_INET;
name.sin_port = htons(local_port);
name.sin_addr.s_addr = inet_addr(local_src);
@ -91,6 +91,7 @@ int do_tcp_connect( xmlNodePtr p, int *s )
};
memcpy(&addr.s_addr, _host.h_addr_list[0], sizeof(struct in_addr));
memset(&name, 0, sizeof(name));
name.sin_family = AF_INET;
name.sin_port = htons( port );
name.sin_addr = addr;

Loading…
Cancel
Save