mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 06:10:35 +08:00
PX4 layer: Code style fixes
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user