From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 63A01D48B for ; Wed, 29 Mar 2017 15:10:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490793031; x=1522329031; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=z4GlPs5MQM0+ijFieClXRkXcjgoAWjdX2sfMkTwd1Zs=; b=Avk6NUACTGHWP+xW260OYIr4ts6MA/n5Rbby+imr3VQlKgHGG1DsE6Tt o9+nuE/SO9i4ira0YwRg1TDPckBwEw==; Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2017 06:10:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,241,1486454400"; d="scan'208";a="839655268" Received: from sivswdev01.ir.intel.com ([10.237.217.45]) by FMSMGA003.fm.intel.com with ESMTP; 29 Mar 2017 06:10:12 -0700 From: Bruce Richardson To: olivier.matz@6wind.com Cc: dev@dpdk.org, Bruce Richardson Date: Wed, 29 Mar 2017 14:09:38 +0100 Message-Id: <20170329130941.31190-12-bruce.richardson@intel.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20170329130941.31190-1-bruce.richardson@intel.com> References: <20170328203606.27457-1-bruce.richardson@intel.com> <20170329130941.31190-1-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH v5 11/14] ring: reduce scope of local variables X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2017 13:10:31 -0000 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 Reviewed-by: Yuanhan Liu Acked-by: Olivier Matz --- 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 2b6896b..07dc895 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -285,6 +285,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)) { \ @@ -311,6 +312,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)) { \ @@ -361,7 +363,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 */ @@ -431,7 +432,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; @@ -495,7 +495,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 */ @@ -566,7 +565,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