testlibraw: Fix printing of card name
Testlibraw always showed the name of the first card rather than the
name of the current card.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
diff --git a/tools/testlibraw.c b/tools/testlibraw.c
index fbeb273..d8a0702 100644
--- a/tools/testlibraw.c
+++ b/tools/testlibraw.c
@@ -226,11 +226,15 @@
int test_card(int card)
{
raw1394handle_t handle;
- struct raw1394_portinfo pinf;
+ struct raw1394_portinfo *portinfo;
tag_handler_t std_handler;
struct pollfd pfd;
int i, l, n, numcards, retval, s;
+ portinfo = malloc(sizeof(*portinfo) * (card + 1));
+ if (!portinfo)
+ return -1;
+
handle = raw1394_new_handle();
if (!handle) {
@@ -240,6 +244,7 @@
perror("couldn't get handle");
printf(not_loaded);
}
+ free(portinfo);
return -1;
}
@@ -249,7 +254,7 @@
raw1394_get_generation(handle));
}
- numcards = raw1394_get_port_info(handle, &pinf, 1);
+ numcards = raw1394_get_port_info(handle, portinfo, card + 1);
if (numcards < card)
perror("couldn't get card info");
else if (card == 0)
@@ -259,7 +264,7 @@
if (numcards <= card)
goto out;
- printf("\ncard %d, name: %s\n", card, pinf.name);
+ printf("\ncard %d, name: %s\n", card, portinfo[card].name);
if (raw1394_set_port(handle, card) < 0) {
perror("couldn't set port");
@@ -344,6 +349,7 @@
perror("poll failed");
out:
raw1394_destroy_handle(handle);
+ free(portinfo);
return numcards;
}