From e5d8dde920f81dab0f8b2f6eb25361744170de26 Mon Sep 17 00:00:00 2001 From: zhuoshuguo Date: Thu, 22 Jun 2017 11:36:55 +0200 Subject: [PATCH] gnrc_priority_queue: updated coding style. --- sys/include/net/gnrc/priority_pktqueue.h | 14 ++++---- .../priority_pktqueue/priority_pktqueue.c | 35 +++++++++---------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/sys/include/net/gnrc/priority_pktqueue.h b/sys/include/net/gnrc/priority_pktqueue.h index eb3c6867bf..d60e6fc381 100644 --- a/sys/include/net/gnrc/priority_pktqueue.h +++ b/sys/include/net/gnrc/priority_pktqueue.h @@ -24,8 +24,9 @@ #define NET_GNRC_PRIORITY_PKTQUEUE_H #include -#include -#include + +#include "priority_queue.h" +#include "net/gnrc/pkt.h" #ifdef __cplusplus extern "C" { @@ -83,6 +84,7 @@ static inline void gnrc_priority_pktqueue_node_init(gnrc_priority_pktqueue_node_ static inline void gnrc_priority_pktqueue_init(gnrc_priority_pktqueue_t *queue) { gnrc_priority_pktqueue_t qn = PRIORITY_PKTQUEUE_INIT; + *queue = qn; } @@ -100,7 +102,7 @@ uint32_t gnrc_priority_pktqueue_length(gnrc_priority_pktqueue_t *queue); * * @param[out] queue the gnrc priority packet queue, must not be NULL */ -void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t* queue); +void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t *queue); /** * @brief Get first element and remove it from @p queue @@ -109,7 +111,7 @@ void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t* queue); * * @return the old head */ -gnrc_pktsnip_t* gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t* queue); +gnrc_pktsnip_t *gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t *queue); /** * @brief Get first element from @p queue without removing @@ -118,7 +120,7 @@ gnrc_pktsnip_t* gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t* queue); * * @return the head of @p queue */ -gnrc_pktsnip_t* gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t* queue); +gnrc_pktsnip_t *gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t *queue); /** * @brief add @p node into @p queue based on its priority @@ -126,7 +128,7 @@ gnrc_pktsnip_t* gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t* queue); * @param[in,out] queue the gnrc priority packet queue, must not be NULL * @param[in] node the node to add. */ -void gnrc_priority_pktqueue_push(gnrc_priority_pktqueue_t* queue, +void gnrc_priority_pktqueue_push(gnrc_priority_pktqueue_t *queue, gnrc_priority_pktqueue_node_t *node); #ifdef __cplusplus diff --git a/sys/net/gnrc/priority_pktqueue/priority_pktqueue.c b/sys/net/gnrc/priority_pktqueue/priority_pktqueue.c index 726d289d9d..c083f23be8 100644 --- a/sys/net/gnrc/priority_pktqueue/priority_pktqueue.c +++ b/sys/net/gnrc/priority_pktqueue/priority_pktqueue.c @@ -20,7 +20,7 @@ */ #include "net/gnrc/pktbuf.h" -#include +#include "net/gnrc/priority_pktqueue.h" /******************************************************************************/ @@ -33,51 +33,50 @@ static inline void _free_node(gnrc_priority_pktqueue_node_t *node) /******************************************************************************/ -gnrc_pktsnip_t* gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t* queue) +gnrc_pktsnip_t *gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t *queue) { - if(!queue || (gnrc_priority_pktqueue_length(queue) == 0)){ + if (!queue || (gnrc_priority_pktqueue_length(queue) == 0)) { return NULL; } priority_queue_node_t *head = priority_queue_remove_head(queue); - gnrc_pktsnip_t* pkt = (gnrc_pktsnip_t*) head->data; + gnrc_pktsnip_t *pkt = (gnrc_pktsnip_t *) head->data; _free_node((gnrc_priority_pktqueue_node_t *)head); return pkt; } /******************************************************************************/ -gnrc_pktsnip_t* gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t* queue) +gnrc_pktsnip_t *gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t *queue) { - if(!queue || (gnrc_priority_pktqueue_length(queue) == 0)){ + if (!queue || (gnrc_priority_pktqueue_length(queue) == 0)) { return NULL; } return (gnrc_pktsnip_t *)queue->first->data; } /******************************************************************************/ -void gnrc_priority_pktqueue_push(gnrc_priority_pktqueue_t* queue, - gnrc_priority_pktqueue_node_t *node) +void gnrc_priority_pktqueue_push(gnrc_priority_pktqueue_t *queue, + gnrc_priority_pktqueue_node_t *node) { assert(queue != NULL); assert(node != NULL); assert(node->pkt != NULL); - assert(sizeof(unsigned int) == sizeof(gnrc_pktsnip_t*)); + assert(sizeof(unsigned int) == sizeof(gnrc_pktsnip_t *)); priority_queue_add(queue, (priority_queue_node_t *)node); } /******************************************************************************/ -void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t* queue) +void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t *queue) { assert(queue != NULL); - if(gnrc_priority_pktqueue_length(queue) == 0){ + if (gnrc_priority_pktqueue_length(queue) == 0) { return; } - gnrc_priority_pktqueue_node_t* node; - while( (node = (gnrc_priority_pktqueue_node_t *)priority_queue_remove_head(queue)) ) - { + gnrc_priority_pktqueue_node_t *node; + while ((node = (gnrc_priority_pktqueue_node_t *)priority_queue_remove_head(queue))) { gnrc_pktbuf_release(node->pkt); _free_node(node); } @@ -90,13 +89,13 @@ uint32_t gnrc_priority_pktqueue_length(gnrc_priority_pktqueue_t *queue) uint32_t length = 0; priority_queue_node_t *node = queue->first; - if(!node){ + if (!node) { return length; } - length ++; - while(node->next!=NULL){ - length ++; + length++; + while (node->next != NULL) { + length++; node = node->next; } return length;