diff --git a/src/platforms/posix/px4_layer/px4_posix_impl.cpp b/src/platforms/posix/px4_layer/px4_posix_impl.cpp index a3ab78df55..30f4cf0f0c 100644 --- a/src/platforms/posix/px4_layer/px4_posix_impl.cpp +++ b/src/platforms/posix/px4_layer/px4_posix_impl.cpp @@ -89,11 +89,11 @@ void init(int argc, char *argv[], const char *app_name) printf("\n"); // set the threads name - #ifdef __PX4_DARWIN +#ifdef __PX4_DARWIN (void)pthread_setname_np(app_name); - #else +#else (void)pthread_setname_np(pthread_self(), app_name); - #endif +#endif } uint64_t get_time_micros() diff --git a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp b/src/platforms/posix/px4_layer/px4_posix_tasks.cpp index 623e0f123a..e05cc5432b 100644 --- a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp +++ b/src/platforms/posix/px4_layer/px4_posix_tasks.cpp @@ -75,7 +75,7 @@ static task_entry taskmap[PX4_MAX_TASKS] = {}; typedef struct { px4_main_t entry; - const char* name; + const char *name; int argc; char *argv[]; // strings are allocated after the @@ -87,11 +87,11 @@ static void *entry_adapter(void *ptr) int rv; // set the threads name - #ifdef __PX4_DARWIN +#ifdef __PX4_DARWIN rv = pthread_setname_np(data->name); - #else +#else rv = pthread_setname_np(pthread_self(), data->name); - #endif +#endif if (rv) { PX4_ERR("px4_task_spawn_cmd: failed to set name of thread %d %d\n", rv, errno); @@ -367,23 +367,24 @@ const char *getprogname() return "Unknown App"; } -int px4_prctl(int option, const char* arg2, unsigned pid) +int px4_prctl(int option, const char *arg2, unsigned pid) { int rv; switch (option) { - case PR_SET_NAME: - // set the threads name - #ifdef __PX4_DARWIN - rv = pthread_setname_np(arg2); - #else - rv = pthread_setname_np(pthread_self(), arg2); - #endif - break; - default: - rv = -1; - PX4_WARN("FAILED SETTING TASK NAME"); - break; + case PR_SET_NAME: + // set the threads name +#ifdef __PX4_DARWIN + rv = pthread_setname_np(arg2); +#else + rv = pthread_setname_np(pthread_self(), arg2); +#endif + break; + + default: + rv = -1; + PX4_WARN("FAILED SETTING TASK NAME"); + break; } return rv; diff --git a/src/platforms/posix/px4_layer/px4_sem.cpp b/src/platforms/posix/px4_layer/px4_sem.cpp index 9abd25bc59..777741ef06 100644 --- a/src/platforms/posix/px4_layer/px4_sem.cpp +++ b/src/platforms/posix/px4_layer/px4_sem.cpp @@ -72,6 +72,7 @@ int px4_sem_wait(px4_sem_t *s) if (s->value < 0) { ret = pthread_cond_wait(&(s->wait), &(s->lock)); + } else { ret = 0; } @@ -97,14 +98,15 @@ int px4_sem_timedwait(px4_sem_t *s, const struct timespec *abstime) if (s->value < 0) { ret = pthread_cond_timedwait(&(s->wait), &(s->lock), abstime); + } else { ret = 0; } int err = errno; - #ifdef __PX4_DARWIN +#ifdef __PX4_DARWIN err = ret; - #endif +#endif if (err != 0 && err != ETIMEDOUT) { setbuf(stdout, NULL); @@ -132,6 +134,7 @@ int px4_sem_post(px4_sem_t *s) if (s->value <= 0) { ret = pthread_cond_signal(&(s->wait)); + } else { ret = 0; }