summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-10-07 11:37:35 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-10-07 11:37:35 +0000
commit0b635145d3a16f4e6bb4182956917a320afc1bd7 (patch)
tree83a56b7225f564a1a6d3c3a12a7f4dab3505ceff
parentconfigure cleanup (diff)
fixed build with -Wall
added build support for clang git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@67 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
-rw-r--r--src/cfg_parser.rl1
-rw-r--r--src/clients.c2
-rwxr-xr-xsrc/configure21
-rw-r--r--src/daemon.h6
-rw-r--r--src/listener.c4
-rw-r--r--src/log.c4
-rw-r--r--src/sig_handler.c4
-rw-r--r--src/tcp.c7
-rw-r--r--src/tcpproxy.c1
9 files changed, 34 insertions, 16 deletions
diff --git a/src/cfg_parser.rl b/src/cfg_parser.rl
index 39836ab..03adbcc 100644
--- a/src/cfg_parser.rl
+++ b/src/cfg_parser.rl
@@ -30,6 +30,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
diff --git a/src/clients.c b/src/clients.c
index 696e2e4..869733b 100644
--- a/src/clients.c
+++ b/src/clients.c
@@ -76,7 +76,7 @@ static int handle_connect(client_t* c, int32_t buffer_size_)
return -1;
int error = 0;
- int len = sizeof(error);
+ socklen_t len = sizeof(error);
if(getsockopt(c->fd_[1], SOL_SOCKET, SO_ERROR, &error, &len)==-1) {
log_printf(ERROR, "Error on getsockopt(): %s", strerror(errno));
return -1;
diff --git a/src/configure b/src/configure
index 90bd304..aa9cb83 100755
--- a/src/configure
+++ b/src/configure
@@ -29,8 +29,7 @@
TARGET=`uname -s`
EBUILD_COMPAT=0
-CFLAGS='-g -O2'
-LDFLAGS='-g -Wall -O2'
+USE_CLANG=0
PREFIX='/usr/local'
BINDIR=''
@@ -50,6 +49,7 @@ print_usage() {
echo " --no-manpage dont't install manpage"
echo " --examplesdir=<DIR> the path to the examples files (default: $PREFIX/share/examples)"
echo " --no-examples dont't install example files"
+ echo " --use-clang use clang/llvm as compiler/linker"
}
for arg
@@ -58,6 +58,9 @@ do
--target=*)
TARGET=${arg#--target=}
;;
+ --use-clang)
+ USE_CLANG=1
+ ;;
--prefix=*)
PREFIX=${arg#--prefix=}
;;
@@ -101,6 +104,16 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then
exit 1
fi
+if [ $USE_CLANG -eq 0 ]; then
+ CFLAGS='-g -Wall -O2'
+ LDFLAGS='-g -Wall -O2'
+ COMPILER='gcc'
+else
+ CFLAGS='-g -O2'
+ LDFLAGS='-g -O2'
+ COMPILER='clang'
+fi
+
rm -f config.h
rm -f include.mk
case $TARGET in
@@ -137,8 +150,8 @@ cat > include.mk <<EOF
# do not edit this file directly
# use ./configure instead
-TARGET := '$TARGET'
-CC := gcc
+TARGET := $TARGET
+CC := $COMPILER
CFLAGS := $CFLAGS
LDFLAGS := $LDFLAGS
STRIP := strip
diff --git a/src/daemon.h b/src/daemon.h
index a910e4a..ebb7780 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -52,7 +52,7 @@ int priv_init(priv_info_t* priv, const char* username, const char* groupname)
priv->pw_ = getpwnam(username);
if(!priv->pw_) {
- log_printf(ERROR, "unkown user %s", username);
+ log_printf(ERROR, "unknown user %s", username);
return -1;
}
@@ -62,7 +62,7 @@ int priv_init(priv_info_t* priv, const char* username, const char* groupname)
priv->gr_ = getgrgid(priv->pw_->pw_gid);
if(!priv->gr_) {
- log_printf(ERROR, "unkown group %s", groupname);
+ log_printf(ERROR, "unknown group %s", groupname);
return -1;
}
@@ -114,6 +114,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/listener.c b/src/listener.c
index e3d36cb..abb0f6f 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -217,7 +217,7 @@ static listener_t* find_zombie_listener(listeners_t* list, tcp_endpoint_t* local
slist_element_t* tmp = list->first_;
while(tmp) {
listener_t* l = (listener_t*)tmp->data_;
- if(l && l->state_ == ZOMBIE && l->local_end_.len_ == local_end->len_ &&
+ if(l && l->state_ == ZOMBIE && l->local_end_.len_ == local_end->len_ &&
!memcmp(&(l->local_end_.addr_), &(local_end->addr_), local_end->len_))
return l;
tmp = tmp->next_;
@@ -229,7 +229,7 @@ static listener_t* find_zombie_listener(listeners_t* list, tcp_endpoint_t* local
int listeners_update(listeners_t* list)
{
if(!list)
- return;
+ return 0;
slist_element_t* tmp = list->first_;
while(tmp) {
diff --git a/src/log.c b/src/log.c
index c3aa346..dd75cea 100644
--- a/src/log.c
+++ b/src/log.c
@@ -239,8 +239,8 @@ void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len)
int offset = snprintf(msg, MSG_LENGTH_MAX, "dump(%d): ", len);
if(offset < 0)
return;
- uint8_t* ptr = &msg[offset];
-
+ char* ptr = &msg[offset];
+
for(i=0; i < len; i++) {
if(((i+1)*3) >= (MSG_LENGTH_MAX - offset))
break;
diff --git a/src/sig_handler.c b/src/sig_handler.c
index cc385cb..9ee05c4 100644
--- a/src/sig_handler.c
+++ b/src/sig_handler.c
@@ -28,13 +28,13 @@
#include "datatypes.h"
#include "log.h"
-
#include "sig_handler.h"
-#include <errno.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
static int sig_pipe_fds[2];
diff --git a/src/tcp.c b/src/tcp.c
index 4067f15..1ab751c 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -25,6 +25,7 @@
* along with tcpproxy. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@@ -40,7 +41,6 @@
char* tcp_endpoint_to_string(tcp_endpoint_t e)
{
- size_t addrstr_len = 0;
char addrstr[INET6_ADDRSTRLEN + 1], portstr[6], *ret;
char addrport_sep = ':';
@@ -49,12 +49,13 @@ char* tcp_endpoint_to_string(tcp_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;
}
diff --git a/src/tcpproxy.c b/src/tcpproxy.c
index 7645c39..382b8eb 100644
--- a/src/tcpproxy.c
+++ b/src/tcpproxy.c
@@ -34,6 +34,7 @@
#include "datatypes.h"
#include "options.h"
#include "string_list.h"
+#include "sig_handler.h"
#include "log.h"
#include "daemon.h"