Received: from eggs.gnu.org ([2001:4830:134:3::10]:51646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm0eC-00085h-Aw for qemu-devel@nongnu.org; Wed, 05 Nov 2014 08:29:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm0e7-0000ss-Fu for qemu-devel@nongnu.org; Wed, 05 Nov 2014 08:29:16 -0500 From: Markus Armbruster References: <1415174992-13246-1-git-send-email-syeon.hwang@samsung.com> <5459DBE1.30509@redhat.com> <545A0288.4010905@gnu.org> <545A05CC.4050109@redhat.com> <545A1BAE.4070802@gnu.org> Date: Wed, 05 Nov 2014 14:29:05 +0100 In-Reply-To: <545A1BAE.4070802@gnu.org> (Paolo Bonzini's message of "Wed, 05 Nov 2014 13:44:30 +0100") Message-ID: <87bnolpyhq.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] error: fixed error_set_errno() to deal with a negative type of os_error. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: SeokYeon Hwang , paolo.bonzini@gmail.com, qemu-devel@nongnu.org, Max Reitz Paolo Bonzini writes: > On 05/11/2014 12:11, Max Reitz wrote: >> >> Of course I understand, but this patch doesn't make matters worse, as >> long as there are not systems which have negative values for errno >> (which I think we generally assume not to exist throughout qemu). That's >> why I'm fine with it. We should fix the callers but I don't see why we >> shouldn't apply this patch as well. >> >> A similar issue already came up and led to commit b276d2499, where >> callers of error_setg_errno() assumed that it would not clobber errno, >> so we fixed some of the callers but also applied that commit which just >> saves errno because there's no reason not to. > > I think side effect are a different matter than misuse of QEMU. Yes. error_setg_errno() had an unclear contract regarding errno. Some callers unjustifiedly assumed that it preserves errno. We clearly needed to clarify the contract. Both "preserves" and "doesn't preserve" make sense. We picked the one that saves us fixing up callers. error_setg_errno()'s contract regarding os_error isn't spelled out, but the general errno contract applies by association: needs to be non-negative. > There are "only" 157 calls to error_setg_errno; 67 use "errno" as the > argument, and 4 use an explicit errno value (one of them is the wrong > -EBUSY). The other 86 seem correct and should not be hard to audit. Negative value is probably just a sign error, but it *could* be a logic error. I'd rather not sweep the latter under the carpet. > Let's instead add an assertion check to error_setg_errno. Yes, please.