Revision 41012841 src/net_helper-udp.c

View differences:

src/net_helper-udp.c
281 281
{
282 282
  int n;
283 283

  
284
	if (s)
284
	if (s && node_ip(s, addr, len)>=0)
285 285
	{
286
		if (node_ip(s, addr, len) < 0) {
287
			return -1;
288
		}
289 286
		n = snprintf(addr + strlen(addr), len - strlen(addr) - 1, ":%d", node_port(s));
290 287
	} else
291 288
		n = snprintf(addr, len , "None");
......
362 359

  
363 360
int node_ip(const struct nodeID *s, char *ip, int len)
364 361
{
362
	int res = 0;
365 363
  switch (s->addr.ss_family)
366 364
  {
367 365
    case AF_INET:
......
371 369
      inet_ntop(s->addr.ss_family, &((const struct sockaddr_in6 *)&s->addr)->sin6_addr, ip, len);
372 370
      break;
373 371
    default:
372
			res = -1;
374 373
      break;
375 374
  }
376 375
  if (!ip) {
377 376
	  perror("inet_ntop");
378
	  return -1;
377
		res = -1;
379 378
  }
380
  return 1;
379
  return res;
381 380
}
382 381

  
383 382
int node_port(const struct nodeID *s)

Also available in: Unified diff