projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enable and fix many extra warnings supported by GCC and Clang.
[tinc]
/
src
/
fd_device.c
diff --git
a/src/fd_device.c
b/src/fd_device.c
index
8ac51fa
..
6e85be0
100644
(file)
--- a/
src/fd_device.c
+++ b/
src/fd_device.c
@@
-1,7
+1,7
@@
/*
fd_device.c -- Interaction with Android tun fd
Copyright (C) 2001-2005 Ivo Timmermans,
/*
fd_device.c -- Interaction with Android tun fd
Copyright (C) 2001-2005 Ivo Timmermans,
- 2001-20
16
Guus Sliepen <guus@tinc-vpn.org>
+ 2001-20
22
Guus Sliepen <guus@tinc-vpn.org>
2009 Grzegorz Dymarek <gregd72002@googlemail.com>
2016-2020 Pacien TRAN-GIRARD <pacien@pacien.net>
2009 Grzegorz Dymarek <gregd72002@googlemail.com>
2016-2020 Pacien TRAN-GIRARD <pacien@pacien.net>
@@
-20,16
+20,17
@@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "system.h"
+
+#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#include <sys/un.h>
-#include "system.h"
#include "conf.h"
#include "device.h"
#include "ethernet.h"
#include "logger.h"
#include "net.h"
#include "route.h"
#include "conf.h"
#include "device.h"
#include "ethernet.h"
#include "logger.h"
#include "net.h"
#include "route.h"
-#include "utils.h"
struct unix_socket_addr {
size_t size;
struct unix_socket_addr {
size_t size;
@@
-41,7
+42,7
@@
static int read_fd(int socket) {
struct iovec iov = {0};
char cmsgbuf[CMSG_SPACE(sizeof(device_fd))];
struct msghdr msg = {0};
struct iovec iov = {0};
char cmsgbuf[CMSG_SPACE(sizeof(device_fd))];
struct msghdr msg = {0};
-
in
t ret;
+
ssize_
t ret;
struct cmsghdr *cmsgptr;
iov.iov_base = &iobuf;
struct cmsghdr *cmsgptr;
iov.iov_base = &iobuf;
@@
-52,7
+53,7
@@
static int read_fd(int socket) {
msg.msg_controllen = sizeof(cmsgbuf);
if((ret = recvmsg(socket, &msg, 0)) < 1) {
msg.msg_controllen = sizeof(cmsgbuf);
if((ret = recvmsg(socket, &msg, 0)) < 1) {
- logger(DEBUG_ALWAYS, LOG_ERR, "Could not read from unix socket (error %
d)!",
ret);
+ logger(DEBUG_ALWAYS, LOG_ERR, "Could not read from unix socket (error %
ld)!", (long)
ret);
return -1;
}
return -1;
}
@@
-114,7
+115,9
@@
end:
}
static struct unix_socket_addr parse_socket_addr(const char *path) {
}
static struct unix_socket_addr parse_socket_addr(const char *path) {
- struct sockaddr_un socket_addr;
+ struct sockaddr_un socket_addr = {
+ .sun_family = AF_UNIX,
+ };
size_t path_length;
if(strlen(path) >= sizeof(socket_addr.sun_path)) {
size_t path_length;
if(strlen(path) >= sizeof(socket_addr.sun_path)) {
@@
-124,7
+127,6
@@
static struct unix_socket_addr parse_socket_addr(const char *path) {
};
}
};
}
- socket_addr.sun_family = AF_UNIX;
strncpy(socket_addr.sun_path, path, sizeof(socket_addr.sun_path));
if(path[0] == '@') {
strncpy(socket_addr.sun_path, path, sizeof(socket_addr.sun_path));
if(path[0] == '@') {
@@
-148,7
+150,7
@@
static bool setup_device(void) {
return false;
}
return false;
}
- if(!get_config_string(lookup_config(config_tree, "Device"), &device)) {
+ if(!get_config_string(lookup_config(
&
config_tree, "Device"), &device)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not read device from configuration!");
return false;
}
logger(DEBUG_ALWAYS, LOG_ERR, "Could not read device from configuration!");
return false;
}
@@
-172,6
+174,10
@@
static bool setup_device(void) {
static void close_device(void) {
close(device_fd);
device_fd = -1;
static void close_device(void) {
close(device_fd);
device_fd = -1;
+ free(iface);
+ iface = NULL;
+ free(device);
+ device = NULL;
}
static inline uint16_t get_ip_ethertype(vpn_packet_t *packet) {
}
static inline uint16_t get_ip_ethertype(vpn_packet_t *packet) {
@@
-195,7
+201,7
@@
static inline void set_etherheader(vpn_packet_t *packet, uint16_t ethertype) {
}
static bool read_packet(vpn_packet_t *packet) {
}
static bool read_packet(vpn_packet_t *packet) {
-
in
t lenin = read(device_fd, DATA(packet) + ETH_HLEN, MTU - ETH_HLEN);
+
ssize_
t lenin = read(device_fd, DATA(packet) + ETH_HLEN, MTU - ETH_HLEN);
if(lenin <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from fd/%d: %s!", device_fd, strerror(errno));
if(lenin <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from fd/%d: %s!", device_fd, strerror(errno));
@@
-234,3
+240,4
@@
const devops_t fd_devops = {
.read = read_packet,
.write = write_packet,
};
.read = read_packet,
.write = write_packet,
};
+#endif