Skip to content

Commit

Permalink
ibdiag: Compare CA device names by using the maximum length between them
Browse files Browse the repository at this point in the history
Compare CA device names by using the maximum length between them in order
to avoid matches of sub strings between CA device names that can match
the wrong device.

Example before the fix:
Input CA name: abc_11
List CA names: abc_1, def_1
When running : ibstat abc_11, the output will be the details of abc_1 even
though abc_11 does not exist.

After the fix, the output of this case will be:
'abc_11' IB device can't be found

Signed-off-by: Haim Boozaglo <haimbo@mellanox.com>
  • Loading branch information
Haim Boozaglo committed Feb 26, 2020
1 parent 964f501 commit f026ac0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions infiniband-diags/ibstat.c
Expand Up @@ -311,8 +311,7 @@ int main(int argc, char *argv[])

if (argc) {
for (node = device_list; node; node = node->next)
if (!strncmp(node->ca_name, argv[0],
strlen(node->ca_name)))
if (!strcmp(node->ca_name, argv[0]))
break;
if (!node)
IBPANIC("'%s' IB device can't be found", argv[0]);
Expand Down

0 comments on commit f026ac0

Please sign in to comment.