changeset 32002:86d37b0e4dbc

Use initializer to avoid leaving struct timeval half-uninitialized.
author reimar
date Wed, 08 Sep 2010 18:25:55 +0000
parents 44c3f5637b8f
children 30a84c65efa4
files udp_sync.c
diffstat 1 files changed, 1 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/udp_sync.c	Wed Sep 08 18:24:13 2010 +0000
+++ b/udp_sync.c	Wed Sep 08 18:25:55 2010 +0000
@@ -87,7 +87,7 @@
     static int done_init_yet = 0;
     static int sockfd;
     if (!done_init_yet) {
-        struct timeval tv;
+        struct timeval tv = { .tv_sec = 30 };
         struct sockaddr_in servaddr = { 0 };
 
         done_init_yet = 1;
@@ -99,7 +99,6 @@
         servaddr.sin_port        = htons(udp_port);
         bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
 
-        tv.tv_sec = 30;
         setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
 
     }