diff options
author | Christian Pointner <equinox@helsinki.at> | 2012-09-25 11:12:27 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2012-09-25 11:12:27 (GMT) |
commit | f03b88e11ce58d7e77a2c43dd8609126d0347fd2 (patch) | |
tree | 75f0819fa31f70508b3077252748715962bc043e /src | |
parent | f2a08b6a4fa298ef7ffa1ab69937b70e05a8131d (diff) |
most fixes for gcc + -Wall and clang
Diffstat (limited to 'src')
-rwxr-xr-x | src/configure | 22 | ||||
-rw-r--r-- | src/daemon.h | 2 | ||||
-rw-r--r-- | src/file_list.c | 10 | ||||
-rw-r--r-- | src/log.c | 2 | ||||
-rw-r--r-- | src/rharchive.c | 1 | ||||
-rw-r--r-- | src/sysexec.c | 4 | ||||
-rw-r--r-- | src/writer.c | 5 |
7 files changed, 31 insertions, 15 deletions
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=<DIR> the path to the bin directory (default: $PREFIX/bin)" echo " --mandir=<DIR> 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 <<EOF # use ./configure instead TARGET := '$TARGET' -CC := gcc +CC := $COMPILER CFLAGS := $CFLAGS LDFLAGS := $LDFLAGS STRIP := strip diff --git a/src/daemon.h b/src/daemon.h index 7a287fe..0657d75 100644 --- a/src/daemon.h +++ b/src/daemon.h @@ -111,6 +111,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/file_list.c b/src/file_list.c index 4d82db7..f3c76fd 100644 --- a/src/file_list.c +++ b/src/file_list.c @@ -22,6 +22,8 @@ * along with rharchive. If not, see <http://www.gnu.org/licenses/>. */ +#define _GNU_SOURCE +#include <unistd.h> #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -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; @@ -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 <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -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) |