From f763c4cc0e7fa1cfced06ff704121b7d22810c49 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Wed, 3 Jun 2015 11:49:28 -0700 Subject: [PATCH] POSIX: fixed type used in USEC2TICKS The macro was using a constant defined as a long instead on an unsigned long. Made corresponsing changes to barosim. Signed-off-by: Mark Charlebois --- src/platforms/posix/drivers/barosim/baro.cpp | 6 +++--- src/platforms/px4_defines.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platforms/posix/drivers/barosim/baro.cpp b/src/platforms/posix/drivers/barosim/baro.cpp index 90f0f71efc..91bd149135 100644 --- a/src/platforms/posix/drivers/barosim/baro.cpp +++ b/src/platforms/posix/drivers/barosim/baro.cpp @@ -439,10 +439,10 @@ BAROSIM::ioctl(device::file_t *filp, int cmd, unsigned long arg) bool want_start = (_measure_ticks == 0); /* convert hz to tick interval via microseconds */ - unsigned ticks = USEC2TICK(1000000 / arg); + unsigned long ticks = USEC2TICK(1000000 / arg); /* check against maximum rate */ - if ((long)ticks < USEC2TICK(BAROSIM_CONVERSION_INTERVAL)) + if (ticks < USEC2TICK(BAROSIM_CONVERSION_INTERVAL)) return -EINVAL; /* update interval for next measurement */ @@ -559,7 +559,7 @@ BAROSIM::cycle() * doing pressure measurements at something close to the desired rate. */ if ((_measure_phase != 0) && - ((long)_measure_ticks > USEC2TICK(BAROSIM_CONVERSION_INTERVAL))) { + (_measure_ticks > USEC2TICK(BAROSIM_CONVERSION_INTERVAL))) { /* schedule a fresh cycle call when we are ready to measure again */ work_queue(HPWORK, diff --git a/src/platforms/px4_defines.h b/src/platforms/px4_defines.h index 41499e69c7..e123a008c5 100644 --- a/src/platforms/px4_defines.h +++ b/src/platforms/px4_defines.h @@ -131,7 +131,7 @@ __BEGIN_DECLS extern long PX4_TICKS_PER_SEC; __END_DECLS -#define USEC_PER_TICK (1000000L/PX4_TICKS_PER_SEC) +#define USEC_PER_TICK (1000000UL/PX4_TICKS_PER_SEC) #define USEC2TICK(x) (((x)+(USEC_PER_TICK/2))/USEC_PER_TICK) #define px4_statfs_buf_f_bavail_t unsigned long