From b5c86c03ebdbf70d92957e6f54a8bbe2a33ad04e Mon Sep 17 00:00:00 2001 From: Luke Yeager Date: Mon, 27 Jul 2020 09:15:56 -0700 Subject: [PATCH] infiniband: replace hard-coded constant with variable --- src/infiniband.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/infiniband.c b/src/infiniband.c index 5467a6251..c70c824d6 100644 --- a/src/infiniband.c +++ b/src/infiniband.c @@ -55,6 +55,8 @@ static int ib_glob_ports(glob_t *g) { return glob("/sys/class/infiniband/*/ports/*/state", GLOB_NOSORT, NULL, g); } +static const int device_tok_idx = 3, port_tok_idx = 5; + static int ib_parse_glob_port(char *path, char **device, char **port) { char *tok, *saveptr = NULL; int j = 0; @@ -62,9 +64,9 @@ static int ib_parse_glob_port(char *path, char **device, char **port) { *port = NULL; tok = strtok_r(path, "/", &saveptr); while (tok != NULL) { - if (j == 3) + if (j == device_tok_idx) *device = tok; - else if (j == 5) { + else if (j == port_tok_idx) { *port = tok; break; } -- 2.39.5