Browse Source

PX4 layer: Code style fixes

sbg
Lorenz Meier 9 years ago
parent
commit
069ebebb27
  1. 6
      src/platforms/posix/px4_layer/px4_posix_impl.cpp
  2. 35
      src/platforms/posix/px4_layer/px4_posix_tasks.cpp
  3. 7
      src/platforms/posix/px4_layer/px4_sem.cpp

6
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"); printf("\n");
// set the threads name // set the threads name
#ifdef __PX4_DARWIN #ifdef __PX4_DARWIN
(void)pthread_setname_np(app_name); (void)pthread_setname_np(app_name);
#else #else
(void)pthread_setname_np(pthread_self(), app_name); (void)pthread_setname_np(pthread_self(), app_name);
#endif #endif
} }
uint64_t get_time_micros() uint64_t get_time_micros()

35
src/platforms/posix/px4_layer/px4_posix_tasks.cpp

@ -75,7 +75,7 @@ static task_entry taskmap[PX4_MAX_TASKS] = {};
typedef struct { typedef struct {
px4_main_t entry; px4_main_t entry;
const char* name; const char *name;
int argc; int argc;
char *argv[]; char *argv[];
// strings are allocated after the // strings are allocated after the
@ -87,11 +87,11 @@ static void *entry_adapter(void *ptr)
int rv; int rv;
// set the threads name // set the threads name
#ifdef __PX4_DARWIN #ifdef __PX4_DARWIN
rv = pthread_setname_np(data->name); rv = pthread_setname_np(data->name);
#else #else
rv = pthread_setname_np(pthread_self(), data->name); rv = pthread_setname_np(pthread_self(), data->name);
#endif #endif
if (rv) { if (rv) {
PX4_ERR("px4_task_spawn_cmd: failed to set name of thread %d %d\n", rv, errno); 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"; 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; int rv;
switch (option) { switch (option) {
case PR_SET_NAME: case PR_SET_NAME:
// set the threads name // set the threads name
#ifdef __PX4_DARWIN #ifdef __PX4_DARWIN
rv = pthread_setname_np(arg2); rv = pthread_setname_np(arg2);
#else #else
rv = pthread_setname_np(pthread_self(), arg2); rv = pthread_setname_np(pthread_self(), arg2);
#endif #endif
break; break;
default:
rv = -1; default:
PX4_WARN("FAILED SETTING TASK NAME"); rv = -1;
break; PX4_WARN("FAILED SETTING TASK NAME");
break;
} }
return rv; return rv;

7
src/platforms/posix/px4_layer/px4_sem.cpp

@ -72,6 +72,7 @@ int px4_sem_wait(px4_sem_t *s)
if (s->value < 0) { if (s->value < 0) {
ret = pthread_cond_wait(&(s->wait), &(s->lock)); ret = pthread_cond_wait(&(s->wait), &(s->lock));
} else { } else {
ret = 0; ret = 0;
} }
@ -97,14 +98,15 @@ int px4_sem_timedwait(px4_sem_t *s, const struct timespec *abstime)
if (s->value < 0) { if (s->value < 0) {
ret = pthread_cond_timedwait(&(s->wait), &(s->lock), abstime); ret = pthread_cond_timedwait(&(s->wait), &(s->lock), abstime);
} else { } else {
ret = 0; ret = 0;
} }
int err = errno; int err = errno;
#ifdef __PX4_DARWIN #ifdef __PX4_DARWIN
err = ret; err = ret;
#endif #endif
if (err != 0 && err != ETIMEDOUT) { if (err != 0 && err != ETIMEDOUT) {
setbuf(stdout, NULL); setbuf(stdout, NULL);
@ -132,6 +134,7 @@ int px4_sem_post(px4_sem_t *s)
if (s->value <= 0) { if (s->value <= 0) {
ret = pthread_cond_signal(&(s->wait)); ret = pthread_cond_signal(&(s->wait));
} else { } else {
ret = 0; ret = 0;
} }

Loading…
Cancel
Save