Improved handling of NULL condition.

pull/936/head
Jeremy Brodt 2015-02-27 10:01:30 -06:00
parent b53b67ecad
commit 6bc00fda8a
2 changed files with 9 additions and 10 deletions

View File

@ -117,17 +117,16 @@ void us_ticker_remove_event(ticker_event_t *obj) {
__enable_irq(); __enable_irq();
} }
timestamp_t us_ticker_get_next_timestamp(void) { int us_ticker_get_next_timestamp(timestamp_t *timestamp) {
int ret = 0;
/* if head is NULL, there are no pending events */
__disable_irq(); __disable_irq();
if (head != NULL) {
if (head == NULL) { *timestamp = head->timestamp;
__enable_irq(); ret = 1;
return 0;
} }
timestamp_t next_timestamp = head->timestamp;
__enable_irq(); __enable_irq();
return next_timestamp; return ret;
} }

View File

@ -43,7 +43,7 @@ void us_ticker_irq_handler(void);
void us_ticker_insert_event(ticker_event_t *obj, timestamp_t timestamp, uint32_t id); void us_ticker_insert_event(ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
void us_ticker_remove_event(ticker_event_t *obj); void us_ticker_remove_event(ticker_event_t *obj);
timestamp_t us_ticker_get_next_timestamp(void); int us_ticker_get_next_timestamp(timestamp_t *timestamp);
#ifdef __cplusplus #ifdef __cplusplus
} }