aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/airspeed
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-08-28 18:31:27 +1000
committerLorenz Meier <lm@inf.ethz.ch>2013-08-28 11:16:30 +0200
commitfdbc09e2a53281b8dda7c48676dcf695a79ba373 (patch)
treefbd2549feee63bf5936dcd44644ac9688eecffc1 /src/drivers/airspeed
parentad732ee3a146b40c2b600eb78f804086105a4c57 (diff)
downloadpx4-firmware-fdbc09e2a53281b8dda7c48676dcf695a79ba373.tar.gz
px4-firmware-fdbc09e2a53281b8dda7c48676dcf695a79ba373.tar.bz2
px4-firmware-fdbc09e2a53281b8dda7c48676dcf695a79ba373.zip
avoid counters going above limit in INCREMENT()
when using INCREMENT() the counter would temporarily read equal to limit, which could cause an issue if the task is preempted. (this macro should be in a common header, though which header?)
Diffstat (limited to 'src/drivers/airspeed')
-rw-r--r--src/drivers/airspeed/airspeed.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/drivers/airspeed/airspeed.h b/src/drivers/airspeed/airspeed.h
index 89dfb22d7..b87494b40 100644
--- a/src/drivers/airspeed/airspeed.h
+++ b/src/drivers/airspeed/airspeed.h
@@ -165,5 +165,5 @@ protected:
};
/* helper macro for handling report buffer indices */
-#define INCREMENT(_x, _lim) do { _x++; if (_x >= _lim) _x = 0; } while(0)
+#define INCREMENT(_x, _lim) do { __typeof__(_x) _tmp = _x+1; if (_tmp >= _lim) _tmp = 0; _x = _tmp; } while(0)