From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id BEA23AFD1 for ; Tue, 17 Jun 2014 20:41:01 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 17 Jun 2014 11:35:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,495,1400050800"; d="scan'208";a="559038244" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 17 Jun 2014 11:41:16 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5HIfF9H007853; Tue, 17 Jun 2014 19:41:15 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s5HIfFW3025376; Tue, 17 Jun 2014 19:41:15 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s5HIfFAS025372; Tue, 17 Jun 2014 19:41:15 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Tue, 17 Jun 2014 19:41:12 +0100 Message-Id: <1403030472-25060-1-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] testpmd: Simplify logic in error branch X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jun 2014 18:41:02 -0000 Simplifiy the logic in the error checking branch. Rather than having a single error branch which checked both RX and TX conditions and made extensive use of the ? operator, move the error checking explicitly into the RX and TX individual branches. The original code caused compilation issues when attempting compilation with clang on BSD, due to type mismatches. This change fixes the issues while making the code easier to read and maintain overall. Signed-off-by: Bruce Richardson --- app/test-pmd/parameters.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index aa0e2bf..3ff4f81 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -316,14 +316,14 @@ parse_queue_stats_mapping_config(const char *q_arg, int is_rx) return -1; } - if (is_rx ? (nb_rx_queue_stats_mappings >= MAX_RX_QUEUE_STATS_MAPPINGS) : - (nb_tx_queue_stats_mappings >= MAX_TX_QUEUE_STATS_MAPPINGS)) { - printf("exceeded max number of %s queue statistics mappings: %hu\n", - is_rx ? "RX" : "TX", - is_rx ? nb_rx_queue_stats_mappings : nb_tx_queue_stats_mappings); - return -1; - } if (!is_rx) { + if ((nb_tx_queue_stats_mappings >= + MAX_TX_QUEUE_STATS_MAPPINGS)) { + printf("exceeded max number of TX queue " + "statistics mappings: %hu\n", + nb_tx_queue_stats_mappings); + return -1; + } tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id = (uint8_t)int_fld[FLD_PORT]; tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id = @@ -333,6 +333,13 @@ parse_queue_stats_mapping_config(const char *q_arg, int is_rx) ++nb_tx_queue_stats_mappings; } else { + if ((nb_rx_queue_stats_mappings >= + MAX_RX_QUEUE_STATS_MAPPINGS)) { + printf("exceeded max number of RX queue " + "statistics mappings: %hu\n", + nb_rx_queue_stats_mappings); + return -1; + } rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id = (uint8_t)int_fld[FLD_PORT]; rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id = -- 1.9.3