* [dpdk-dev] [PATCH] testpmd: Simplify logic in error branch
@ 2014-06-17 18:41 Bruce Richardson
2014-06-18 23:06 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Bruce Richardson @ 2014-06-17 18:41 UTC (permalink / raw)
To: dev
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 <bruce.richardson@intel.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] testpmd: Simplify logic in error branch
2014-06-17 18:41 [dpdk-dev] [PATCH] testpmd: Simplify logic in error branch Bruce Richardson
@ 2014-06-18 23:06 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2014-06-18 23:06 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
> 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 <bruce.richardson@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Applied for version 1.7.0.
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-18 23:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-17 18:41 [dpdk-dev] [PATCH] testpmd: Simplify logic in error branch Bruce Richardson
2014-06-18 23:06 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).