From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MbWIl-000735-HB for qemu-devel@nongnu.org; Thu, 13 Aug 2009 05:08:51 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MbWIg-0006qx-4V for qemu-devel@nongnu.org; Thu, 13 Aug 2009 05:08:50 -0400 Received: from [199.232.76.173] (port=56687 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MbWIf-0006qS-Qb for qemu-devel@nongnu.org; Thu, 13 Aug 2009 05:08:45 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59116) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MbWIe-0007I2-Ul for qemu-devel@nongnu.org; Thu, 13 Aug 2009 05:08:45 -0400 Subject: Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks. References: <1250092766-23986-1-git-send-email-kraxel@redhat.com> <200908122028.41012.paul@codesourcery.com> <4A831C47.3070309@redhat.com> <873a7w2q6n.fsf@pike.pond.sub.org> <4A83C562.1090802@redhat.com> From: Markus Armbruster Date: Thu, 13 Aug 2009 11:06:41 +0200 In-Reply-To: <4A83C562.1090802@redhat.com> (Gerd Hoffmann's message of "Thu\, 13 Aug 2009 09\:48\:50 +0200") Message-ID: <87tz0cytem.fsf@pike.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Paul Brook , qemu-devel@nongnu.org Gerd Hoffmann writes: > On 08/13/09 08:17, Markus Armbruster wrote: > >> One problem with passing up error codes is diagnostics: when we reach >> the point where we can decide on policy, we've lost the context for >> precise diagnostics. net.c tackles that problem by passing the >> destination for diagnostics down, to let code report errors with >> config_error() while remaining unaware of policy. > > I don't want pass additional arguments all the way down just for error > reporting. It sure is tedious and ugly. > One thing we can do is storing the error message in a > global or thread-local variable (much like errno). We could also add > a errmsg field to DeviceState and use that. > >> Issue also exists elsewhere. Try monitor command "pci_add auto >> model=?". > > Thats why I'd tend to use a global variable. It also works in case > don't have a DeviceState. I find stashing error messages for later printing rather awkward. Do you provide space for one fixed-sized message? Or arbitrary length? Arbitrary number of messages? Once you start to malloc(), you get to worry about free()... Meh. I'd rather use the global or thread-local state to hold the sink for the messages, then send the messages there as we make them. No memory management worries.