From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 24 02:56:58 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8893316A41F for ; Mon, 24 Oct 2005 02:56:58 +0000 (GMT) (envelope-from dr2867@pacbell.net) Received: from smtp111.sbc.mail.mud.yahoo.com (smtp111.sbc.mail.mud.yahoo.com [68.142.198.210]) by mx1.FreeBSD.org (Postfix) with SMTP id 2FBAE43D46 for ; Mon, 24 Oct 2005 02:56:58 +0000 (GMT) (envelope-from dr2867@pacbell.net) Received: (qmail 74113 invoked from network); 24 Oct 2005 02:56:57 -0000 Received: from unknown (HELO ?192.168.0.190?) (dr2867.business@pacbell.net@68.126.211.246 with plain) by smtp111.sbc.mail.mud.yahoo.com with SMTP; 24 Oct 2005 02:56:57 -0000 Message-ID: <435C4D7C.7080504@pacbell.net> Date: Sun, 23 Oct 2005 19:57:00 -0700 From: Daniel Rudy User-Agent: Mozilla/5.0 (X11R6; UNIX; FreeBSD/i386 5.4-RELEASE-p7; en-US; ja-JP; rv:1.7.12) Gecko/20050915 MultiZilla/1.6.2.0c Mnenhy/0.7.2.0 X-Accept-Language: en-us, en, ja MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: devinfo(3) problem... X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2005 02:56:58 -0000 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