From owner-freebsd-usb@FreeBSD.ORG Tue Jan 15 16:38:03 2008 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D15216A417 for ; Tue, 15 Jan 2008 16:38:03 +0000 (UTC) (envelope-from stefan.lambrev@moneybookers.com) Received: from blah.sun-fish.com (blah.sun-fish.com [217.18.249.150]) by mx1.freebsd.org (Postfix) with ESMTP id C87AD13C4D1 for ; Tue, 15 Jan 2008 16:38:02 +0000 (UTC) (envelope-from stefan.lambrev@moneybookers.com) Received: by blah.sun-fish.com (Postfix, from userid 1002) id 081591B10EF1; Tue, 15 Jan 2008 17:38:01 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on blah.cmotd.com X-Spam-Level: X-Spam-Status: No, score=-10.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, J_CHICKENPOX_33 autolearn=no version=3.2.3 Received: from hater.haters.org (hater.cmotd.com [192.168.3.125]) by blah.sun-fish.com (Postfix) with ESMTP id 3D5921B10ED2; Tue, 15 Jan 2008 17:37:58 +0100 (CET) Message-ID: <478CE165.7060001@moneybookers.com> Date: Tue, 15 Jan 2008 18:37:57 +0200 From: Stefan Lambrev User-Agent: Thunderbird 2.0.0.9 (X11/20071120) MIME-Version: 1.0 To: freebsd-usb@freebsd.org References: <477BC1A3.5080406@moneybookers.com> <200801021837.51376.hselasky@c2i.net> <477CD474.6080302@moneybookers.com> <200801032154.32107.hselasky@c2i.net> <478BE02A.7050100@moneybookers.com> <478CBCDB.6090203@moneybookers.com> In-Reply-To: <478CBCDB.6090203@moneybookers.com> Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.91.2/5483/Mon Jan 14 15:45:01 2008 on blah.cmotd.com X-Virus-Status: Clean Cc: Subject: Re: Problem with usb4bsd rev566 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2008 16:38:03 -0000 Greetings, Sorry to reply again to myself :) Stefan Lambrev wrote: > -cut- > > cc -c -O2 -pipe -fno-strict-aliasing -march=prescott -std=c99 -Wall > -Wredundant-decls -Wnested-externs -Wstrict-prototypes > -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef > -Wno-pointer-sign -fformat-extensions -nostdinc -I. -I/usr/src/sys > -I/usr/src/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS > -include opt_global.h -fno-common -finline-limit=8000 --param > inline-unit-growth=100 --param large-function-growth=1000 > -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-mmx > -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -ffreestanding -Werror > /usr/src/sys/dev/usb/usb_transfer.c > cc1: warnings being treated as errors > /usr/src/sys/dev/usb/usb_transfer.c: In function 'usbd_callback_intr_td': > /usr/src/sys/dev/usb/usb_transfer.c:2094: warning: 'xfer[2]' may be > used uninitialized in this function > /usr/src/sys/dev/usb/usb_transfer.c:2094: warning: 'xfer[3]' may be > used uninitialized in this function > *** Error code 1 > > Stop in /usr/obj/usr/src/sys/CORE. > *** Error code 1 > > Stop in /usr/src. > *** Error code 1 > > Stop in /usr/src. > I think I got it, why the compiler complains and refuses to build this. What we have in usbd_callback_intr_td() is little strange "goto" cycle (at least strange for me): repeat: if (xfer[0]) { LIST_REMOVE(xfer[0], done_list); xfer[0]->done_list.le_prev = NULL; xfer[1] = LIST_FIRST(&(info->done_head)); if (xfer[1] == NULL) { dropcount = 1; goto lockchange_0; } At this point xfer[2] & xfer[3] are not defined and if xfer[1] == NULL we go here: lockchange_0: mtx_unlock(info->usb_mtx); /* * we exploit the fact that the mutex is the same for * all callbacks */ mtx_lock(info->priv_mtx); /* call callback(s) */ usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK); Here we already know that xfer[1] == NULL (but the compiler does not!) and I think the logic can be changed to remove the second check if (xfer[1] == NULL) { goto lockchange_1; } usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK); We can reach to this point if xfer[1] == NULL, but the compiler sees reference to xfer[2] so it complains - may be used uninitialized in this function if (xfer[2] == NULL) { goto lockchange_1; } usbd_callback_wrapper(xfer[2], info, USBD_CONTEXT_CALLBACK); Same situation with xfer[3] ! if (xfer[3] == NULL) { goto lockchange_1; } usbd_callback_wrapper(xfer[3], info, USBD_CONTEXT_CALLBACK); What I did to comfort the compiler is to add xfer[2] = NULL; xfer[3] = NULL; On the next line after label "repeat" (should work better if added before the label?) As I said more adequate patch is to fully remove lockchange_0 label and do all things in the first check. It will be more optimized and more readable :) I'll test what I did and do I still have working usb and will report back ASAP ;) P.S. usbd_callback_intr_td() is declared and called only in i4b/trunk/i4b/src/sys/dev/usb/usb_transfer.c -- Best Wishes, Stefan Lambrev ICQ# 24134177