The below included simple program reliably printfs "error 4\n" on 5.4-RELEASE. Am I understanding something wrong or is this a bug in libdevinfo?

To continue on this however, if you put say sleep(5) between devinfo_free() and the second devinfo_init() and manage to change the device configuration during the sleep (tested with pluggin in/out a USB memory), the program terminates with no errors. I've run into other oddities with devinfo as well, but in much more complex situations so they might just as well be variations of this simple example.

Juho

/* save this as test.c and compile:
* cc -o test test.c -ldevinfo
*/

#include <sys/types.h>
#include <devinfo.h>

int
main () {
       struct devinfo_dev *root;

       if (devinfo_init()) {
               printf("error 1\n");
               return -1;
       }
       if ((root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) == 0) {
               printf("error 2\n");
               return -1;
       }
       devinfo_free();

       if (devinfo_init()) {
               printf("error 3\n");
               return -1;
       }
       if ((root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) == 0) {
               printf("error 4\n");
               return -1;
       }
       devinfo_free();

       printf("no errors\n");
       return 0;
}

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to