Thread (116 messages) 116 messages, 7 authors, 2017-04-13
STALE3355d
Revisions (4)
  1. v1 current
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 [diff vs current]

[PATCH v1 11/14] ring: reduce scope of local variables

From: Bruce Richardson <hidden>
Date: 2017-02-23 17:25:05
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

The local variable i is only used for loop control so define it in
the enqueue and dequeue blocks directly, rather than at the function
level.

Signed-off-by: Bruce Richardson <redacted>
---
 lib/librte_ring/rte_ring.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index afd5367..db50ce9 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -280,6 +280,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);
  * Placed here since identical code needed in both
  * single and multi producer enqueue functions */
 #define ENQUEUE_PTRS() do { \
+	unsigned int i; \
 	const uint32_t size = r->size; \
 	uint32_t idx = prod_head & mask; \
 	if (likely(idx + n < size)) { \
@@ -306,6 +307,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);
  * Placed here since identical code needed in both
  * single and multi consumer dequeue functions */
 #define DEQUEUE_PTRS() do { \
+	unsigned int i; \
 	uint32_t idx = cons_head & mask; \
 	const uint32_t size = r->size; \
 	if (likely(idx + n < size)) { \
@@ -356,7 +358,6 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,
 	uint32_t cons_tail, free_entries;
 	const unsigned int max = n;
 	int success;
-	unsigned int i;
 	uint32_t mask = r->mask;
 
 	/* move prod.head atomically */
@@ -426,7 +427,6 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,
 {
 	uint32_t prod_head, cons_tail;
 	uint32_t prod_next, free_entries;
-	unsigned int i;
 	uint32_t mask = r->mask;
 
 	prod_head = r->prod.head;
@@ -490,7 +490,6 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,
 	uint32_t cons_next, entries;
 	const unsigned max = n;
 	int success;
-	unsigned int i;
 	uint32_t mask = r->mask;
 
 	/* move cons.head atomically */
@@ -561,7 +560,6 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table,
 {
 	uint32_t cons_head, prod_tail;
 	uint32_t cons_next, entries;
-	unsigned int i;
 	uint32_t mask = r->mask;
 
 	cons_head = r->cons.head;
-- 
2.9.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help