diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2012-06-30 19:13:35 +0200 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2012-06-30 19:13:35 +0200 |
commit | a24ab81d5777b4553c9c8474c58a69b0b2ba98de (patch) | |
tree | 437e9f37083caf510781a97130fbbbdb6d3c0016 | |
parent | d50f7381b21e6f720b49464de1c2886950115c9c (diff) | |
download | libraw1394-a24ab81d5777b4553c9c8474c58a69b0b2ba98de.tar.gz |
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>
-rw-r--r-- | tools/testlibraw.c | 12 |
1 files changed, 9 insertions, 3 deletions
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 @@ 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; } |