summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2012-09-25 11:45:31 +0000
committerChristian Pointner <equinox@anytun.org>2012-09-25 11:45:31 +0000
commit4dda2b162fdab27197f371bb85842da581aee834 (patch)
treef0b10a52e541160c1739444923066c83e1c491ff /src
parentconfigure script cleanup (diff)
-Wall cleanup
Diffstat (limited to 'src')
-rwxr-xr-xsrc/configure2
-rw-r--r--src/daemon.h2
-rw-r--r--src/linux/tun.c6
-rw-r--r--src/log.c3
-rw-r--r--src/options.h1
-rw-r--r--src/sig_handler.c2
-rw-r--r--src/sysexec.c5
-rw-r--r--src/uanytun.c4
-rw-r--r--src/udp.c9
9 files changed, 23 insertions, 11 deletions
diff --git a/src/configure b/src/configure
index 2f5cb5e..d91b396 100755
--- a/src/configure
+++ b/src/configure
@@ -38,7 +38,7 @@ TARGET=`uname -s`
EBUILD_COMPAT=0
-CFLAGS='-g -O2'
+CFLAGS='-g -Wall -O2'
LDFLAGS='-g -Wall -O2'
CRYPTO_LIB='gcrypt'
diff --git a/src/daemon.h b/src/daemon.h
index 0113fcd..9e6f1b2 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -122,6 +122,8 @@ int do_chroot(const char* chrootdir)
log_printf(ERROR, "can't change to /: %s", strerror(errno));
return -1;
}
+
+ return 0;
}
void daemonize()
diff --git a/src/linux/tun.c b/src/linux/tun.c
index 85cdc01..43370f0 100644
--- a/src/linux/tun.c
+++ b/src/linux/tun.c
@@ -33,6 +33,7 @@
* along with uAnytun. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _GNU_SOURCE
#include <stdio.h>
#include "datatypes.h"
@@ -116,6 +117,7 @@ int tun_init(tun_device_t* dev, const char* dev_name, const char* dev_type, cons
int tun_init_post(tun_device_t* dev)
{
// nothing yet
+ return 0;
}
void tun_close(tun_device_t* dev)
@@ -192,8 +194,8 @@ void tun_do_ifconfig(tun_device_t* dev)
return;
char* mtu_str = NULL;
- asprintf(&mtu_str, "%d", dev->mtu_);
- if(!mtu_str) {
+ int len = asprintf(&mtu_str, "%d", dev->mtu_);
+ if(len == -1) {
log_printf(ERROR, "Execution of ifconfig failed");
return;
}
diff --git a/src/log.c b/src/log.c
index ae323e9..d789123 100644
--- a/src/log.c
+++ b/src/log.c
@@ -35,6 +35,7 @@
#include "datatypes.h"
+#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -246,7 +247,7 @@ void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len)
int offset = snprintf(msg, MSG_LENGTH_MAX, "dump(%d): ", len);
if(offset < 0)
return;
- u_int8_t* ptr = &msg[offset];
+ char* ptr = &msg[offset];
for(i=0; i < len; i++) {
if(((i+1)*3) >= (MSG_LENGTH_MAX - offset))
diff --git a/src/options.h b/src/options.h
index ccc5044..66c9e99 100644
--- a/src/options.h
+++ b/src/options.h
@@ -92,6 +92,7 @@ void options_parse_post(options_t* opt);
void options_default(options_t* opt);
void options_clear(options_t* opt);
void options_print_usage();
+void options_print_version();
void options_print(options_t* opt);
#endif
diff --git a/src/sig_handler.c b/src/sig_handler.c
index 92b1d02..7c5c695 100644
--- a/src/sig_handler.c
+++ b/src/sig_handler.c
@@ -42,7 +42,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
-
+#include <string.h>
static int sig_pipe_fds[2];
diff --git a/src/sysexec.c b/src/sysexec.c
index 1d3df91..708d8d0 100644
--- a/src/sysexec.c
+++ b/src/sysexec.c
@@ -35,6 +35,7 @@
#include "datatypes.h"
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -42,6 +43,7 @@
#include <sys/wait.h>
#include <sys/select.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include "sysexec.h"
@@ -83,7 +85,8 @@ int uanytun_exec(const char* script, char* const argv[], char* const evp[])
// if execve returns, an error occurred, but logging doesn't work
// because we closed all file descriptors, so just write errno to
// pipe and call exit
- write(pipefd[1], (void*)(&errno), sizeof(errno));
+ int ret = write(pipefd[1], (void*)(&errno), sizeof(errno));
+ if(ret == -1) exit(-1);
exit(-1);
}
close(pipefd[1]);
diff --git a/src/uanytun.c b/src/uanytun.c
index be67d77..d804d05 100644
--- a/src/uanytun.c
+++ b/src/uanytun.c
@@ -236,7 +236,7 @@ int main_loop(tun_device_t* dev, udp_t* sock, options_t* opt)
int return_value = 0;
int sig_fd = signal_init();
if(sig_fd < 0)
- return_value -1;
+ return_value = -1;
FD_SET(sig_fd, &readfds);
nfds = (nfds < sig_fd) ? sig_fd : nfds;
@@ -372,7 +372,7 @@ int main(int argc, char* argv[])
log_printf(NOTICE, "executing post-up script '%s'", opt.post_up_script_);
char* const argv[] = { opt.post_up_script_, dev.actual_name_, NULL };
char* const evp[] = { NULL };
- int ret = uanytun_exec(opt.post_up_script_, argv, evp);
+ uanytun_exec(opt.post_up_script_, argv, evp);
}
diff --git a/src/udp.c b/src/udp.c
index e6865bd..1491d75 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -33,6 +33,9 @@
* along with uAnytun. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _GNU_SOURCE
+#include <stdio.h>
+
#include "datatypes.h"
#include "udp.h"
@@ -240,7 +243,6 @@ void udp_close(udp_t* sock)
char* udp_endpoint_to_string(udp_endpoint_t e)
{
- size_t addrstr_len = 0;
char addrstr[INET6_ADDRSTRLEN + 1], portstr[6], *ret;
char addrport_sep = ':';
@@ -249,12 +251,13 @@ char* udp_endpoint_to_string(udp_endpoint_t e)
case AF_INET: addrport_sep = ':'; break;
case AF_INET6: addrport_sep = '.'; break;
case AF_UNSPEC: return NULL;
- default: asprintf(&ret, "unknown address type"); return ret;
+ default: return strdup("unknown address type");
}
int errcode = getnameinfo((struct sockaddr *)&(e.addr_), e.len_, addrstr, sizeof(addrstr), portstr, sizeof(portstr), NI_NUMERICHOST | NI_NUMERICSERV);
if (errcode != 0) return NULL;
- asprintf(&ret, "%s%c%s", addrstr, addrport_sep ,portstr);
+ int len = asprintf(&ret, "%s%c%s", addrstr, addrport_sep ,portstr);
+ if(len == -1) return NULL;
return ret;
}