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>
This commit is contained in:
Stefan Richter 2012-06-30 19:13:35 +02:00
parent d50f7381b2
commit a24ab81d57
1 changed files with 9 additions and 3 deletions

View File

@ -226,11 +226,15 @@ read_cycle_timer(raw1394handle_t handle)
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 @@ int test_card(int card)
perror("couldn't get handle");
printf(not_loaded);
}
free(portinfo);
return -1;
}
@ -249,7 +254,7 @@ int test_card(int card)
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 @@ int test_card(int card)
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 @@ int test_card(int card)
perror("poll failed");
out:
raw1394_destroy_handle(handle);
free(portinfo);
return numcards;
}