openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

commit f54e95f9c5072c66379700dd745b018bb0e4ff99
parent 23369c45a093003def30456fd13b56f3916f26dc
Author: Broadcom SDK Release <sdk.releases@broadcom.com>
Date:   Mon, 22 Jul 2019 12:44:42 -0700

SDK-185088: Refactored the code to remove reliance upon i, which was only use...

Devices: 56980_A0,56980_B0
Module: CLI

Symptom:
 dport_map_port_* mapping to align logical/internal port results into
display issue with PS command

Refactored the code to remove reliance upon i, which was only used to
see if it matched the last port passed in the string from the command
line.  Instead, used the actual iterator, p, to index the dport map and
match the "logical port" passed in by the string from the command line

Diffstat:
Msdk-6.5.16/src/appl/diag/util.c | 36+++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/sdk-6.5.16/src/appl/diag/util.c b/sdk-6.5.16/src/appl/diag/util.c @@ -1073,33 +1073,27 @@ parse_pbmp(int unit, char *s, soc_pbmp_t *pbmp) /* Treat port as internal port number */ plast = DPORT_FROM_PORT(unit, port); } else { - /* Port number is port index + 1 */ - i = 0; plast = -1; - /* coverity[overrun-local] */ - /* Initially, DPORT_SOC_PBMP_ITER macro was being used for - iterating and converting all the dports to ports. Problem - arises when there are spare ports. For the case of - invalid / spare ports, we do not increment i and we get the - wrong value of p which is not meant for the invalid port. - This causes one port shift in the information. So instead - of using the macro, we are iterating by using for loop - */ + + /* Iterate through the dport map and find the corresponding + * logical port. If the logical port is valid and is the last + * one passed in as the arg, mark it as the last port + */ for (p = 0; p < SOC_DPORT_MAX; p++) { tp = soc_dport_to_port(unit, p); - if (tp == -1) { - i++; - continue; - } - if (tp >= 0 && SOC_PBMP_MEMBER(pbmp_temp, p)) { - i += 1; - if (i == port) { - plast = p; - break; + + /* If the logical port is valid and mapped, and if it's + * the last port from the string passed above, mark it + * as the last port and break out of the loop + */ + if (tp >= 0 && SOC_PBMP_MEMBER(pbmp_temp, tp)) { + if (p == port) { + plast = p; + break; + } } } } - } if (plast < 0) { return -1; /* error: port out of range */ }