Received: from eggs.gnu.org ([2001:4830:134:3::10]:59714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLuKs-0005YX-0q for qemu-devel@nongnu.org; Thu, 12 Feb 2015 09:01:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLuKm-0002a7-Gl for qemu-devel@nongnu.org; Thu, 12 Feb 2015 09:01:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLuKm-0002Zr-9w for qemu-devel@nongnu.org; Thu, 12 Feb 2015 09:01:36 -0500 From: Markus Armbruster Date: Thu, 12 Feb 2015 15:01:26 +0100 Message-ID: <87pp9f1b61.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] Several sheepdog functions mix up -1 and -errno in return values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mitake.hitoshi@lab.ntt.co.jp, namei.unix@gmail.com, sheepdog@lists.wpkg.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Two common conventions for functions returning int that may fail: 1. Return non-negative value on success, -1 value on failure. 2. Return non-negative value on success, a negative errno error code on failure. Both work. But mixing them in the same function is not a good idea. Suspicious functions in block/sheepdog.c include: * read_write_object() May return 0, -EIO or the value of do_req(). do_req() returns srco.ret. do_co_req() may set it to the value of send_co_req(). I don't think that one returns -errno. * do_sd_create() May return 0, -EIO or the value of connect_to_sdog(). I don't think the latter returns -errno. I suspect there are more. Please audit the file for this kind of mistake. Good opportunity to document for each function what it's supposed to return.