Skip to content

Commit 706649c

Browse files
committed
inet: Improve code quality for FreeBSD
For issue #74
1 parent 4af1149 commit 706649c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

C/inet/libinetsocket.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#else
1010
#define LIBSOCKET_LINUX 1
1111
#endif
12-
#define LIBSOCKET_FREEBSD 0
13-
#define LIBSOCKET_SUNOS 0
1412

1513
#include <errno.h>
1614
#include <net/if.h>
@@ -467,6 +465,10 @@ ssize_t recvfrom_inet_dgram_socket(int sfd, void *buffer, size_t size,
467465
addrptr = &(((struct sockaddr_in6 *)&client)->sin6_addr);
468466
addrlen = sizeof(struct in6_addr);
469467
sport = ntohs(((struct sockaddr_in6 *)&client)->sin6_port);
468+
} else {
469+
#ifdef VERBOSE
470+
debug_write("recvfrom_inet_dgram_socket: Unknown address family");
471+
#endif
470472
}
471473

472474
if (NULL ==
@@ -500,7 +502,6 @@ ssize_t recvfrom_inet_dgram_socket(int sfd, void *buffer, size_t size,
500502
int connect_inet_dgram_socket(int sfd, const char *host, const char *service) {
501503
struct addrinfo *result, *result_check, hint;
502504
struct sockaddr_storage oldsockaddr;
503-
struct sockaddr deconnect;
504505
socklen_t oldsockaddrlen = sizeof(struct sockaddr_storage);
505506
int return_value;
506507
#ifdef VERBOSE
@@ -514,6 +515,7 @@ int connect_inet_dgram_socket(int sfd, const char *host, const char *service) {
514515
// socket although we don't do so. This is not very severe for the
515516
// application
516517
#ifndef __FreeBSD__
518+
struct sockaddr deconnect;
517519
memset(&deconnect, 0, sizeof(struct sockaddr));
518520

519521
deconnect.sa_family = AF_UNSPEC;
@@ -868,6 +870,11 @@ int accept_inet_stream_socket(int sfd, char *src_host, size_t src_host_len,
868870
addrptr = &(((struct sockaddr_in6 *)&client_info)->sin6_addr);
869871
in_addrlen = sizeof(struct in6_addr);
870872
sport = ntohs(((struct sockaddr_in6 *)&client_info)->sin6_port);
873+
} else {
874+
#ifdef VERBOSE
875+
debug_write("accept_inet_stream_socket: Unknown address family");
876+
#endif
877+
return -1;
871878
}
872879

873880
if (NULL ==

0 commit comments

Comments
 (0)