aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2007-05-03 11:09:44 -0700
committerRoland Dreier <rolandd@cisco.com>2007-05-03 11:09:44 -0700
commit40fd5fd7f299b471acd450fd8a1f46b2cf17650c (patch)
tree5503470063341aeeed3e1a20aad6dececcafd6ad
parent6907bce0787f7bdffe50fd71bd86d23b13395608 (diff)
downloadlibibverbs-40fd5fd7f299b471acd450fd8a1f46b2cf17650c.tar.gz
Fix call to ibv_free_device_list() in pingpong examples
When a -d option to specify which device to use is passed to the pingpong examples, they iterate through the device list by incrementing the dev_list pointer. This means that the call to ibv_free_device_list() may not get the right pointer. Fix this by using an index to iterate through the array and leaving the dev_list pointer itself alone. Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--examples/rc_pingpong.c6
-rw-r--r--examples/srq_pingpong.c6
-rw-r--r--examples/uc_pingpong.c6
-rw-r--r--examples/ud_pingpong.c6
4 files changed, 16 insertions, 8 deletions
diff --git a/examples/rc_pingpong.c b/examples/rc_pingpong.c
index 4548653..258eb8f 100644
--- a/examples/rc_pingpong.c
+++ b/examples/rc_pingpong.c
@@ -590,9 +590,11 @@ int main(int argc, char *argv[])
return 1;
}
} else {
- for (; (ib_dev = *dev_list); ++dev_list)
- if (!strcmp(ibv_get_device_name(ib_dev), ib_devname))
+ int i;
+ for (i = 0; dev_list[i]; ++i)
+ if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname))
break;
+ ib_dev = dev_list[i];
if (!ib_dev) {
fprintf(stderr, "IB device %s not found\n", ib_devname);
return 1;
diff --git a/examples/srq_pingpong.c b/examples/srq_pingpong.c
index 796bd7d..490ad0a 100644
--- a/examples/srq_pingpong.c
+++ b/examples/srq_pingpong.c
@@ -681,9 +681,11 @@ int main(int argc, char *argv[])
return 1;
}
} else {
- for (; (ib_dev = *dev_list); ++dev_list)
- if (!strcmp(ibv_get_device_name(ib_dev), ib_devname))
+ int i;
+ for (i = 0; dev_list[i]; ++i)
+ if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname))
break;
+ ib_dev = dev_list[i];
if (!ib_dev) {
fprintf(stderr, "IB device %s not found\n", ib_devname);
return 1;
diff --git a/examples/uc_pingpong.c b/examples/uc_pingpong.c
index b5886c0..b6051c8 100644
--- a/examples/uc_pingpong.c
+++ b/examples/uc_pingpong.c
@@ -578,9 +578,11 @@ int main(int argc, char *argv[])
return 1;
}
} else {
- for (; (ib_dev = *dev_list); ++dev_list)
- if (!strcmp(ibv_get_device_name(ib_dev), ib_devname))
+ int i;
+ for (i = 0; dev_list[i]; ++i)
+ if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname))
break;
+ ib_dev = dev_list[i];
if (!ib_dev) {
fprintf(stderr, "IB device %s not found\n", ib_devname);
return 1;
diff --git a/examples/ud_pingpong.c b/examples/ud_pingpong.c
index 08ab05c..c631e25 100644
--- a/examples/ud_pingpong.c
+++ b/examples/ud_pingpong.c
@@ -581,9 +581,11 @@ int main(int argc, char *argv[])
return 1;
}
} else {
- for (; (ib_dev = *dev_list); ++dev_list)
- if (!strcmp(ibv_get_device_name(ib_dev), ib_devname))
+ int i;
+ for (i = 0; dev_list[i]; ++i)
+ if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname))
break;
+ ib_dev = dev_list[i];
if (!ib_dev) {
fprintf(stderr, "IB device %s not found\n", ib_devname);
return 1;