aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-11-21 13:20:15 +0100
committerStefan Sperling <ssperling@sysmocom.de>2018-11-21 13:23:35 +0100
commit3cf5229fa0502e759d45e8397b2e7341ab418165 (patch)
tree659417491f87a582208476d2875b8fa5707ca0bd
parentcf9e5f8c3302b7ac1c7eb63ff2fcb79df0223980 (diff)
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
-rw-r--r--test_apps/tcp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/test_apps/tcp.c b/test_apps/tcp.c
index 4e24fa5..4cf681d 100644
--- a/test_apps/tcp.c
+++ b/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;