aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranryko <a.shvenke@gmail.com>2018-01-07 18:30:35 +0100
committeranryko <a.shvenke@gmail.com>2018-01-07 18:30:35 +0100
commitc5e402ace9dff0bb5b27ebc8cc553175fbeceb68 (patch)
tree735b964a7464030098d83b4305974e0768da3906
parent547d531bb3088bf00a0ae5777fa09c7893b7b370 (diff)
downloadgnunet-c5e402ace9dff0bb5b27ebc8cc553175fbeceb68.tar.gz
gnunet-c5e402ace9dff0bb5b27ebc8cc553175fbeceb68.zip
Style fixes (mostly tabs to spaces).
-rw-r--r--src/util/crypto_hash.c6
-rw-r--r--src/util/network.c86
2 files changed, 46 insertions, 46 deletions
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index 20c7ca7ff..cce9cf82a 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -69,9 +69,9 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
69 char *np; 69 char *np;
70 70
71 np = GNUNET_STRINGS_data_to_string ((const unsigned char *) block, 71 np = GNUNET_STRINGS_data_to_string ((const unsigned char *) block,
72 sizeof (struct GNUNET_HashCode), 72 sizeof (struct GNUNET_HashCode),
73 (char*) result, 73 (char *) result,
74 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1); 74 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1);
75 GNUNET_assert (NULL != np); 75 GNUNET_assert (NULL != np);
76 *np = '\0'; 76 *np = '\0';
77} 77}
diff --git a/src/util/network.c b/src/util/network.c
index 973878f93..0cb1529a6 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -91,8 +91,8 @@ GNUNET_NETWORK_test_pf (int pf)
91 if (EAFNOSUPPORT == errno) 91 if (EAFNOSUPPORT == errno)
92 return GNUNET_NO; 92 return GNUNET_NO;
93 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 93 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
94 "Failed to create test socket: %s\n", 94 "Failed to create test socket: %s\n",
95 STRERROR (errno)); 95 STRERROR (errno));
96 return GNUNET_SYSERR; 96 return GNUNET_SYSERR;
97 } 97 }
98#if WINDOWS 98#if WINDOWS
@@ -128,21 +128,20 @@ GNUNET_NETWORK_shorten_unixpath (char *unixpath)
128 if (slen < upm) 128 if (slen < upm)
129 return unixpath; /* no shortening required */ 129 return unixpath; /* no shortening required */
130 GNUNET_CRYPTO_hash (unixpath, slen, &sh); 130 GNUNET_CRYPTO_hash (unixpath, slen, &sh);
131 while (16 + 131 while (16 + strlen (unixpath) >= upm)
132 strlen (unixpath) >= upm)
133 { 132 {
134 if (NULL == (end = strrchr (unixpath, '/'))) 133 if (NULL == (end = strrchr (unixpath, '/')))
135 { 134 {
136 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 135 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
137 _("Unable to shorten unix path `%s' while keeping name unique\n"), 136 _("Unable to shorten unix path `%s' while keeping name unique\n"),
138 unixpath); 137 unixpath);
139 GNUNET_free (unixpath); 138 GNUNET_free (unixpath);
140 return NULL; 139 return NULL;
141 } 140 }
142 *end = '\0'; 141 *end = '\0';
143 } 142 }
144 GNUNET_CRYPTO_hash_to_enc (&sh, &ae); 143 GNUNET_CRYPTO_hash_to_enc (&sh, &ae);
145 strncat (unixpath, (char*) ae.encoding, 16); 144 strncat (unixpath, (char *) ae.encoding, 16);
146 return unixpath; 145 return unixpath;
147} 146}
148 147
@@ -239,7 +238,6 @@ GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd,
239 int flags = fcntl (fd->fd, F_GETFL); 238 int flags = fcntl (fd->fd, F_GETFL);
240 239
241 if (flags == -1) 240 if (flags == -1)
242
243 { 241 {
244 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, 242 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
245 "fcntl"); 243 "fcntl");
@@ -311,7 +309,7 @@ socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle *h)
311 309
312 if (0 != 310 if (0 !=
313 setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, 311 setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE,
314 (const void *) &abs_value, 312 (const void *) &abs_value,
315 sizeof (abs_value))) 313 sizeof (abs_value)))
316 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); 314 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
317} 315}
@@ -342,8 +340,10 @@ socket_set_nodelay (const struct GNUNET_NETWORK_Handle *h)
342 const char *abs_value = "1"; 340 const char *abs_value = "1";
343 341
344 if (0 != 342 if (0 !=
345 setsockopt (h->fd, IPPROTO_TCP, TCP_NODELAY, 343 setsockopt (h->fd,
346 (const void *) abs_value, 344 IPPROTO_TCP,
345 TCP_NODELAY,
346 (const void *) abs_value,
347 sizeof (abs_value))) 347 sizeof (abs_value)))
348 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, 348 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
349 "setsockopt"); 349 "setsockopt");
@@ -365,7 +365,7 @@ socket_set_nodelay (const struct GNUNET_NETWORK_Handle *h)
365 */ 365 */
366static int 366static int
367initialize_network_handle (struct GNUNET_NETWORK_Handle *h, 367initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
368 int af, 368 int af,
369 int type) 369 int type)
370{ 370{
371 int eno; 371 int eno;
@@ -409,7 +409,7 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
409#ifdef AF_UNIX 409#ifdef AF_UNIX
410 && (af != AF_UNIX) 410 && (af != AF_UNIX)
411#endif 411#endif
412 ) 412 )
413 socket_set_nodelay (h); 413 socket_set_nodelay (h);
414 return GNUNET_OK; 414 return GNUNET_OK;
415} 415}
@@ -426,7 +426,7 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
426struct GNUNET_NETWORK_Handle * 426struct GNUNET_NETWORK_Handle *
427GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, 427GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
428 struct sockaddr *address, 428 struct sockaddr *address,
429 socklen_t *address_len) 429 socklen_t *address_len)
430{ 430{
431 struct GNUNET_NETWORK_Handle *ret; 431 struct GNUNET_NETWORK_Handle *ret;
432 int eno; 432 int eno;
@@ -443,7 +443,7 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
443 443
444 if (0 == gsn) 444 if (0 == gsn)
445 LOG (GNUNET_ERROR_TYPE_DEBUG, 445 LOG (GNUNET_ERROR_TYPE_DEBUG,
446 "Accepting connection on `%s'\n", 446 "Accepting connection on `%s'\n",
447 GNUNET_a2s ((const struct sockaddr *) &name, 447 GNUNET_a2s ((const struct sockaddr *) &name,
448 namelen)); 448 namelen));
449 } 449 }
@@ -491,9 +491,11 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
491 const int on = 1; 491 const int on = 1;
492 492
493 if (AF_INET6 == desc->af) 493 if (AF_INET6 == desc->af)
494 if (setsockopt (desc->fd, IPPROTO_IPV6, IPV6_V6ONLY, 494 if (setsockopt (desc->fd,
495 (const void *) &on, 495 IPPROTO_IPV6,
496 sizeof (on))) 496 IPV6_V6ONLY,
497 (const void *) &on,
498 sizeof (on)))
497 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, 499 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG,
498 "setsockopt"); 500 "setsockopt");
499 } 501 }
@@ -593,8 +595,8 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc)
593 if (0 != unlink (dirname)) 595 if (0 != unlink (dirname))
594 { 596 {
595 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, 597 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
596 "unlink", 598 "unlink",
597 dirname); 599 dirname);
598 } 600 }
599 else 601 else
600 { 602 {
@@ -1209,8 +1211,8 @@ GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to,
1209 to->handles_size, 1211 to->handles_size,
1210 from->handles_pos * 2); 1212 from->handles_pos * 2);
1211 GNUNET_memcpy (to->handles, 1213 GNUNET_memcpy (to->handles,
1212 from->handles, 1214 from->handles,
1213 from->handles_pos * sizeof (struct GNUNET_NETWORK_Handle *)); 1215 from->handles_pos * sizeof (struct GNUNET_NETWORK_Handle *));
1214 to->handles_pos = from->handles_pos; 1216 to->handles_pos = from->handles_pos;
1215#endif 1217#endif
1216} 1218}
@@ -1327,9 +1329,9 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
1327 int fd; 1329 int fd;
1328 1330
1329 GNUNET_assert (GNUNET_OK == 1331 GNUNET_assert (GNUNET_OK ==
1330 GNUNET_DISK_internal_file_handle_ (h, 1332 GNUNET_DISK_internal_file_handle_ (h,
1331 &fd, 1333 &fd,
1332 sizeof (int))); 1334 sizeof (int)));
1333 FD_SET (fd, 1335 FD_SET (fd,
1334 &fds->sds); 1336 &fds->sds);
1335 fds->nsds = GNUNET_MAX (fd + 1, 1337 fds->nsds = GNUNET_MAX (fd + 1,
@@ -1707,7 +1709,7 @@ initialize_select_thread ()
1707 */ 1709 */
1708int 1710int
1709GNUNET_NETWORK_test_port_free (int ipproto, 1711GNUNET_NETWORK_test_port_free (int ipproto,
1710 uint16_t port) 1712 uint16_t port)
1711{ 1713{
1712 struct GNUNET_NETWORK_Handle *socket; 1714 struct GNUNET_NETWORK_Handle *socket;
1713 int bind_status; 1715 int bind_status;
@@ -1718,37 +1720,35 @@ GNUNET_NETWORK_test_port_free (int ipproto,
1718 struct addrinfo *ai; 1720 struct addrinfo *ai;
1719 1721
1720 GNUNET_snprintf (open_port_str, 1722 GNUNET_snprintf (open_port_str,
1721 sizeof (open_port_str), 1723 sizeof (open_port_str),
1722 "%u", 1724 "%u",
1723 (unsigned int) port); 1725 (unsigned int) port);
1724 socktype = (IPPROTO_TCP == ipproto) 1726 socktype = (IPPROTO_TCP == ipproto) ? SOCK_STREAM : SOCK_DGRAM;
1725 ? SOCK_STREAM
1726 : SOCK_DGRAM;
1727 ret = NULL; 1727 ret = NULL;
1728 memset (&hint, 0, sizeof (hint)); 1728 memset (&hint, 0, sizeof (hint));
1729 hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */ 1729 hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */
1730 hint.ai_socktype = socktype; 1730 hint.ai_socktype = socktype;
1731 hint.ai_protocol = ipproto; 1731 hint.ai_protocol = ipproto;
1732 hint.ai_addrlen = 0; 1732 hint.ai_addrlen = 0;
1733 hint.ai_addr = NULL; 1733 hint.ai_addr = NULL;
1734 hint.ai_canonname = NULL; 1734 hint.ai_canonname = NULL;
1735 hint.ai_next = NULL; 1735 hint.ai_next = NULL;
1736 hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */ 1736 hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */
1737 GNUNET_assert (0 == getaddrinfo (NULL, 1737 GNUNET_assert (0 == getaddrinfo (NULL,
1738 open_port_str, 1738 open_port_str,
1739 &hint, 1739 &hint,
1740 &ret)); 1740 &ret));
1741 bind_status = GNUNET_NO; 1741 bind_status = GNUNET_NO;
1742 for (ai = ret; NULL != ai; ai = ai->ai_next) 1742 for (ai = ret; NULL != ai; ai = ai->ai_next)
1743 { 1743 {
1744 socket = GNUNET_NETWORK_socket_create (ai->ai_family, 1744 socket = GNUNET_NETWORK_socket_create (ai->ai_family,
1745 ai->ai_socktype, 1745 ai->ai_socktype,
1746 ai->ai_protocol); 1746 ai->ai_protocol);
1747 if (NULL == socket) 1747 if (NULL == socket)
1748 continue; 1748 continue;
1749 bind_status = GNUNET_NETWORK_socket_bind (socket, 1749 bind_status = GNUNET_NETWORK_socket_bind (socket,
1750 ai->ai_addr, 1750 ai->ai_addr,
1751 ai->ai_addrlen); 1751 ai->ai_addrlen);
1752 GNUNET_NETWORK_socket_close (socket); 1752 GNUNET_NETWORK_socket_close (socket);
1753 if (GNUNET_OK != bind_status) 1753 if (GNUNET_OK != bind_status)
1754 break; 1754 break;
@@ -1808,7 +1808,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1808 (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us)); 1808 (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us));
1809 } 1809 }
1810 return select (nfds, 1810 return select (nfds,
1811 (NULL != rfds) ? &rfds->sds : NULL, 1811 (NULL != rfds) ? &rfds->sds : NULL,
1812 (NULL != wfds) ? &wfds->sds : NULL, 1812 (NULL != wfds) ? &wfds->sds : NULL,
1813 (NULL != efds) ? &efds->sds : NULL, 1813 (NULL != efds) ? &efds->sds : NULL,
1814 (timeout.rel_value_us == 1814 (timeout.rel_value_us ==
@@ -2178,7 +2178,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
2178 { 2178 {
2179 LOG (GNUNET_ERROR_TYPE_DEBUG, 2179 LOG (GNUNET_ERROR_TYPE_DEBUG,
2180 "Adding the socket event to the array as %d\n", 2180 "Adding the socket event to the array as %d\n",
2181 nhandles); 2181 nhandles);
2182 handle_array[nhandles++] = select_finished_event; 2182 handle_array[nhandles++] = select_finished_event;
2183 if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) 2183 if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
2184 { 2184 {