diff --git a/src/spicelib/devices/ChangeLog b/src/spicelib/devices/ChangeLog index eb703a6fb..348eeb55c 100644 --- a/src/spicelib/devices/ChangeLog +++ b/src/spicelib/devices/ChangeLog @@ -1,3 +1,9 @@ +2000-07-08 Arno W. Peters + + * devlist.c, test-devlist: Additional checks revealed a bug, + first_device() and next_device() should now do what they are + supposed to do. + 2000-07-07 Arno W. Peters * devlist.c, devlist.h: Another step towards diff --git a/src/spicelib/devices/devlist.c b/src/spicelib/devices/devlist.c index a140a65a1..491d85915 100644 --- a/src/spicelib/devices/devlist.c +++ b/src/spicelib/devices/devlist.c @@ -52,10 +52,9 @@ next_device(SPICEdev **current) int index; SPICEdev **ret; - index = (current - devices())/sizeof(SPICEdev *); - printf("index: %d\n", index); + index = current - devices(); if (index < num_devices()) { - ret = current + sizeof(SPICEdev *); + ret = current + 1; } else { ret = NULL; } diff --git a/src/spicelib/devices/test_devlist.c b/src/spicelib/devices/test_devlist.c index 99c7866d8..70ba3a126 100644 --- a/src/spicelib/devices/test_devlist.c +++ b/src/spicelib/devices/test_devlist.c @@ -56,18 +56,21 @@ main(void) int count = 0; int ret; + ret = EXIT_SUCCESS; for (dev = first_device(); dev != NULL; dev = next_device(dev)) { - printf("count: %d\n", count); + if (*dev != DEVices[count]) { + ret = EXIT_FAILURE; + } count++; } - if (count == num_devices() + 1) { + if (ret == EXIT_SUCCESS && count == num_devices() + 1) { printf("PASSED"); ret = EXIT_SUCCESS; } else { printf("FAILED"); ret = EXIT_FAILURE; } - printf(": test_dev\n"); + printf(": test_devlist\n"); return ret; }