Skip to content

Commit

Permalink
POSIX: fixed type used in USEC2TICKS
Browse files Browse the repository at this point in the history
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 <charlebm@gmail.com>
  • Loading branch information
mcharleb committed Jun 3, 2015
1 parent 122c52c commit f763c4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/platforms/posix/drivers/barosim/baro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/px4_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f763c4c

Please sign in to comment.