Consider the following code fragment:
(segment 2) Calling code section: /* get devinfo root nexus */ printf("root ptr: %p\n", root); result = usb_devinfo_root(&root); printf("root ptr: %p\n", root); if (result < 0) { usb_devinfo_close(); return(-1); } /* internal: get devinfo root nexus */ int usb_devinfo_root(struct devinfo_dev **root) { printf("root: %p\n", *root); *root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE); printf("root: %p\n", *root); <---- second call printf if (*root == NULL) { if (usb_param_use_error == TRUE) error("usb.c: usb_devinfo_root: root device not found", errno); if (usb_param_errors_fatal == TRUE) exit(2); return(-1); } return(0); } The problem is that devinfo_handle_to_device always returns a null pointer here. Why? The next code segment, devinfo_handle_to_device returns a proper address. (segment 1) /* get devinfo root nexus */ root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE); if (root == NULL) { devinfo_free(); return(-1); } output: usb_param_devmode: 255 usb_param_devtype: 255 usb_param_mode_pref: 0 ioctl result: -1 devinfo result: 0 found_ioctl: 0 found_devinfo: 1 <---- first call devinfo device name: umass0 usb_devinfo_open result: 0 root ptr: 0x2815769c root: 0x2815769c root: 0x0 <---- second call usb.c: usb_devinfo_root: root device not found: No such file or directory root ptr: 0x0 Fatal: Unable to get device information Now I have made sure that I have called devinfo_free() during the first call before calling devinfo_init() a second time. I tried calling this code branch on the first time, and it executes properly, so why does it fail on the second call? -- Daniel Rudy _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"