diff --git a/src/descrambler/cwc.c b/src/descrambler/cwc.c index b070d817..9a068476 100755 --- a/src/descrambler/cwc.c +++ b/src/descrambler/cwc.c @@ -490,7 +490,6 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid, int enq, uint1 tvhtrace("cwc", "sending message sid %d len %"PRIsize_t" enq %d", sid, len, enq); tvhlog_hexdump("cwc", msg, len); - if (len < 0) return -1; buf[0] = (len - 2) >> 8; buf[1] = (len - 2) & 0xff; diff --git a/src/epggrab/channel.c b/src/epggrab/channel.c index 974bcf38..8cdff425 100644 --- a/src/epggrab/channel.c +++ b/src/epggrab/channel.c @@ -191,7 +191,7 @@ epggrab_channel_t *epggrab_channel_find epggrab_channel_t *ec; static epggrab_channel_t *skel = NULL; if (!skel) skel = calloc(1, sizeof(epggrab_channel_t)); - skel->id = strdupa(id); + skel->id = tvh_strdupa(id); /* Replace / with # */ // Note: this is a bit of a nasty fix for #1774, but will do for now diff --git a/src/idnode.c b/src/idnode.c index f4bfdbdf..ab27207c 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -494,7 +494,7 @@ idnode_cmp_sort case PT_STR: { int r; - const char *stra = strdupa(idnode_get_str(ina, sort->key) ?: ""); + const char *stra = tvh_strdupa(idnode_get_str(ina, sort->key) ?: ""); const char *strb = idnode_get_str(inb, sort->key); if (sort->dir == IS_ASC) r = strcmp(stra ?: "", strb ?: ""); @@ -666,7 +666,7 @@ void idnode_set_sort ( idnode_set_t *is, idnode_sort_t *sort ) { - qsort_r(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_sort, sort); + qsort_r(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_sort, (void*)sort); } void diff --git a/src/input/mpegts/linuxdvb/linuxdvb_mux.c b/src/input/mpegts/linuxdvb/linuxdvb_mux.c index 0ef5ab90..96cfb424 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_mux.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_mux.c @@ -443,7 +443,7 @@ linuxdvb_mux_dvbs_class_orbital_set ( void *o, const void *s ) { int pos, save = 0; char dir; - char *tmp = strdupa(s); + char *tmp = tvh_strdupa(s); linuxdvb_mux_t *lm = o; dir = tmp[strlen(tmp)-1]; diff --git a/src/main.c b/src/main.c index a71d2b8f..cc3c9b11 100644 --- a/src/main.c +++ b/src/main.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -65,6 +64,10 @@ #include "plumbing/transcoding.h" #endif +#ifdef PLATFORM_LINUX +#include +#endif + /* Command line option struct */ typedef struct str_list { @@ -690,9 +693,13 @@ main(int argc, char **argv) /* Make dumpable */ if (opt_dump) { +#ifdef PLATFORM_LINUX if (chdir("/tmp")) tvhwarn("START", "failed to change cwd to /tmp"); prctl(PR_SET_DUMPABLE, 1); +#else + tvhwarn("START", "Coredumps not implemented on your platform"); +#endif } umask(0); diff --git a/src/trap.c b/src/trap.c index 42697906..00664724 100644 --- a/src/trap.c +++ b/src/trap.c @@ -33,6 +33,7 @@ char tvh_binshasum[20]; #include #if ENABLE_EXECINFO #include +#include #endif #include #include @@ -52,6 +53,10 @@ static char tmpbuf[1024]; static char libs[1024]; static char self[PATH_MAX]; +#ifdef PLATFORM_FREEBSD +extern char **environ; +#endif + static void sappend(char *buf, size_t l, const char *fmt, ...) { diff --git a/src/tvheadend.h b/src/tvheadend.h index bc7b5dca..0bb2be80 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -603,12 +603,14 @@ int rmtree ( const char *path ); char *regexp_escape ( const char *str ); +#ifdef PLATFORM_LINUX /* glibc wrapper */ #if !__GLIBC_PREREQ(2,8) void qsort_r(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *, void *), void *aux); #endif +#endif /* PLATFORM_LINUX */ /* printing */ # if __WORDSIZE == 64 diff --git a/src/tvhlog.c b/src/tvhlog.c index ac42dc3c..ece17b33 100644 --- a/src/tvhlog.c +++ b/src/tvhlog.c @@ -307,7 +307,7 @@ void tvhlogv ( const char *file, int line, /* Basic message */ l = 0; if (options & TVHLOG_OPT_THREAD) { - l += snprintf(buf + l, sizeof(buf) - l, "tid %ld: ", pthread_self()); + l += snprintf(buf + l, sizeof(buf) - l, "tid %ld: ", (long)pthread_self()); } l += snprintf(buf + l, sizeof(buf) - l, "%s: ", subsys); if (options & TVHLOG_OPT_FILELINE && severity >= LOG_DEBUG) diff --git a/src/wrappers.c b/src/wrappers.c index 4167b902..4343fc50 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -3,10 +3,17 @@ #include #include /* See NOTES */ #include -#include #include #include +#ifdef PLATFORM_LINUX +#include +#endif + +#ifdef PLATFORM_FREEBSD +#include +#endif + int tvh_open(const char *pathname, int flags, mode_t mode) { @@ -94,12 +101,17 @@ thread_wrapper ( void *p ) { struct thread_state *ts = p; +#if defined(PLATFORM_LINUX) /* Set name */ prctl(PR_SET_NAME, ts->name); +#elif defined(PLATFORM_FREEBSD) + /* Set name of thread */ + pthread_set_name_np(pthread_self(), ts->name); +#endif /* Run */ tvhdebug("thread", "created thread %ld [%s / %p(%p)]", - pthread_self(), ts->name, ts->run, ts->arg); + (long)pthread_self(), ts->name, ts->run, ts->arg); void *r = ts->run(ts->arg); free(ts); @@ -123,6 +135,7 @@ tvhthread_create0 return r; } +#ifdef PLATFORM_LINUX /* * qsort_r wrapper for pre GLIBC 2.8 */ @@ -148,3 +161,4 @@ qsort_r(void *base, size_t nmemb, size_t size, qsort(base, nmemb, size, qsort_r_wrap); } #endif /* GLIBC < 2.8 */ +#endif /* PLATFORM_LINUX */ diff --git a/support/posix.mk b/support/posix.mk index db621b80..404245a9 100644 --- a/support/posix.mk +++ b/support/posix.mk @@ -7,8 +7,8 @@ INSTICON= ${DESTDIR}$(prefix)/share/icons/hicolor/scalable/apps install: ${PROG} ${MAN} install -d ${DESTDIR}${bindir} install ${PROG} ${DESTDIR}${bindir}/tvheadend - install -d ${DESTDIR}${mandir} - install ${MAN} ${DESTDIR}${mandir}/tvheadend.1 + install -d ${DESTDIR}${mandir}/man1 + install ${MAN} ${DESTDIR}${mandir}/man1/tvheadend.1 for bundle in ${BUNDLES}; do \ mkdir -p ${DESTDIR}${datadir}/tvheadend/$$bundle ;\ @@ -19,5 +19,5 @@ install: ${PROG} ${MAN} uninstall: rm -f ${DESTDIR}${bindir}/tvheadend - rm -f ${DESTDIR}${mandir}/tvheadend.1 + rm -f ${DESTDIR}${mandir}/man1/tvheadend.1 rm -rf ${DESTDIR}${datadir}/tvheadend