From f03b88e11ce58d7e77a2c43dd8609126d0347fd2 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 25 Sep 2012 11:12:27 +0000 Subject: most fixes for gcc + -Wall and clang diff --git a/src/configure b/src/configure index 9de0fca..ff09e73 100755 --- a/src/configure +++ b/src/configure @@ -28,13 +28,11 @@ set -e TARGET=`uname -s` EBUILD_COMPAT=0 -CFLAGS='-g -O2' -LDFLAGS='-g -Wall -O2' - PREFIX='/usr/local' BINDIR='' MANDIR='' INSTALLMANPAGE=1 +USE_CLANG=0 print_usage() { echo "configure --help print this" @@ -43,6 +41,7 @@ print_usage() { echo " --bindir= the path to the bin directory (default: $PREFIX/bin)" echo " --mandir= the path to the system man pages (default: $PREFIX/share/man)" echo " --no-manpage dont't install manpage" + echo " --use-clang use clang/llvm as compiler/linker" } for arg @@ -63,6 +62,9 @@ do --no-manpage) INSTALLMANPAGE=0 ;; + --use-clang) + USE_CLANG=1 + ;; --ebuild-compat) EBUILD_COMPAT=1 ;; @@ -85,7 +87,17 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then exit 1 fi -CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-0.10)" +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 + +CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-0.10) -DGST_DISABLE_DEPRECATED" LDFLAGS="$LDFLAGS $(pkg-config --libs gstreamer-0.10)" rm -f include.mk @@ -117,7 +129,7 @@ cat > include.mk <. */ +#define _GNU_SOURCE +#include #include #include #include @@ -77,8 +79,8 @@ file_t* file_list_add(file_list_t* list, struct tm* time, const char* type, cons char name[256]; strftime(name, sizeof(name), format, time); - asprintf(&(tmp->path_), "%s/%s", dir, name); - if(!tmp->path_) { + int len = asprintf(&(tmp->path_), "%s/%s", dir, name); + if(len == -1) { free(tmp); return NULL; } @@ -190,8 +192,8 @@ int open_file(file_t* file) } cnt++; char* tmp; - asprintf(&tmp, "%s.%d", orig_path, cnt); - if(!tmp) { + int len = asprintf(&tmp, "%s.%d", orig_path, cnt); + if(len == -1) { if(orig_path != file->path_) free(orig_path); return -2; diff --git a/src/log.c b/src/log.c index ef8e989..59a6f9f 100644 --- a/src/log.c +++ b/src/log.c @@ -246,7 +246,7 @@ 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)) diff --git a/src/rharchive.c b/src/rharchive.c index 32dee31..3401047 100644 --- a/src/rharchive.c +++ b/src/rharchive.c @@ -34,6 +34,7 @@ #include "options.h" #include "string_list.h" #include "log.h" +#include "sig_handler.h" #include "daemon.h" #include "writer.h" diff --git a/src/sysexec.c b/src/sysexec.c index e7b17e1..d4edc4b 100644 --- a/src/sysexec.c +++ b/src/sysexec.c @@ -24,6 +24,7 @@ #include "datatypes.h" +#include #include #include #include @@ -171,7 +172,8 @@ child_t* rh_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 len = write(pipefd[1], (void*)(&errno), sizeof(errno)); + if(len) exit(-1); exit(-1); } close(pipefd[1]); diff --git a/src/writer.c b/src/writer.c index 68f305c..ce89ad9 100644 --- a/src/writer.c +++ b/src/writer.c @@ -39,7 +39,7 @@ static int init_time_boundaries(writer_t* writer) { if(!writer) - return; + return -1; struct timespec now; clock_gettime(CLOCK_REALTIME, &now); @@ -158,8 +158,6 @@ static int check_boundaries(writer_t* writer) add_fd(writer, writer->next_->fd_); remove_fd(writer, writer->current_->fd_); - - int old_fd = writer->current_->fd_; writer->current_ = writer->next_; writer->next_boundary_.tv_sec += 3600; @@ -178,7 +176,6 @@ static gpointer writer_thread_func(gpointer data) writer_t *writer = (writer_t*)data; log_printf(NOTICE, "writer thread started"); - GstBuffer* buf = NULL; for(;;) { GstClockReturn wret = gst_clock_id_wait(writer->clock_id_, NULL); if(GST_CLOCK_UNSCHEDULED == wret) -- cgit v0.10.2