From a24ab81d5777b4553c9c8474c58a69b0b2ba98de Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 30 Jun 2012 19:13:35 +0200 Subject: [PATCH] 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 --- tools/testlibraw.c | 12 +++++++++--- 1 file 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; }