]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
infiniband: replace hard-coded constant with variable 3494/head
authorLuke Yeager <lyeager@nvidia.com>
Mon, 27 Jul 2020 16:15:56 +0000 (09:15 -0700)
committerLuke Yeager <lyeager@nvidia.com>
Mon, 27 Jul 2020 16:15:56 +0000 (09:15 -0700)
src/infiniband.c

index 5467a62516c84b4088d6a1681962be80bdc8e438..c70c824d6fec496d631fcdc17c5662ed5d9cd49c 100644 (file)
@@ -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;
     }