diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-11 07:48:09 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-11 07:48:09 +0100 |
commit | b52402dbe2d3447b25a46070bdd771c12fd4c55a (patch) | |
tree | 825b9a3349169ce933906685f05ada037fd29570 /apps/mavlink/mavlink_log.c | |
parent | fdf1c712b163deace14dfd8c74a6b1afac6262fb (diff) | |
download | px4-firmware-b52402dbe2d3447b25a46070bdd771c12fd4c55a.tar.gz px4-firmware-b52402dbe2d3447b25a46070bdd771c12fd4c55a.tar.bz2 px4-firmware-b52402dbe2d3447b25a46070bdd771c12fd4c55a.zip |
Fixed code style for mavlink app
Diffstat (limited to 'apps/mavlink/mavlink_log.c')
-rw-r--r-- | apps/mavlink/mavlink_log.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/apps/mavlink/mavlink_log.c b/apps/mavlink/mavlink_log.c index 73d59e76f..ed65fb883 100644 --- a/apps/mavlink/mavlink_log.c +++ b/apps/mavlink/mavlink_log.c @@ -43,39 +43,47 @@ #include <stdlib.h> #include "mavlink_log.h" - -void mavlink_logbuffer_init(struct mavlink_logbuffer *lb, int size) { - lb->size = size; - lb->start = 0; - lb->count = 0; - lb->elems = (struct mavlink_logmessage *)calloc(lb->size, sizeof(struct mavlink_logmessage)); + +void mavlink_logbuffer_init(struct mavlink_logbuffer *lb, int size) +{ + lb->size = size; + lb->start = 0; + lb->count = 0; + lb->elems = (struct mavlink_logmessage *)calloc(lb->size, sizeof(struct mavlink_logmessage)); } - -int mavlink_logbuffer_is_full(struct mavlink_logbuffer *lb) { + +int mavlink_logbuffer_is_full(struct mavlink_logbuffer *lb) +{ return lb->count == (int)lb->size; } - -int mavlink_logbuffer_is_empty(struct mavlink_logbuffer *lb) { - return lb->count == 0; + +int mavlink_logbuffer_is_empty(struct mavlink_logbuffer *lb) +{ + return lb->count == 0; } - -void mavlink_logbuffer_write(struct mavlink_logbuffer *lb, const struct mavlink_logmessage *elem) { - int end = (lb->start + lb->count) % lb->size; - memcpy(&(lb->elems[end]), elem, sizeof(struct mavlink_logmessage)); - if (mavlink_logbuffer_is_full(lb)) { - lb->start = (lb->start + 1) % lb->size; /* full, overwrite */ - } else { - ++lb->count; - } + +void mavlink_logbuffer_write(struct mavlink_logbuffer *lb, const struct mavlink_logmessage *elem) +{ + int end = (lb->start + lb->count) % lb->size; + memcpy(&(lb->elems[end]), elem, sizeof(struct mavlink_logmessage)); + + if (mavlink_logbuffer_is_full(lb)) { + lb->start = (lb->start + 1) % lb->size; /* full, overwrite */ + + } else { + ++lb->count; + } } - -int mavlink_logbuffer_read(struct mavlink_logbuffer *lb, struct mavlink_logmessage *elem) { - if (!mavlink_logbuffer_is_empty(lb)) { - memcpy(elem, &(lb->elems[lb->start]), sizeof(struct mavlink_logmessage)); - lb->start = (lb->start + 1) % lb->size; - --lb->count; - return 0; - } else { - return 1; - } + +int mavlink_logbuffer_read(struct mavlink_logbuffer *lb, struct mavlink_logmessage *elem) +{ + if (!mavlink_logbuffer_is_empty(lb)) { + memcpy(elem, &(lb->elems[lb->start]), sizeof(struct mavlink_logmessage)); + lb->start = (lb->start + 1) % lb->size; + --lb->count; + return 0; + + } else { + return 1; + } } |