From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vtx62-0005uo-0e for qemu-devel@nongnu.org; Fri, 20 Dec 2013 05:14:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vtx5t-0000Cc-JA for qemu-devel@nongnu.org; Fri, 20 Dec 2013 05:14:17 -0500 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]:35970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vtx5t-0000CQ-D5 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 05:14:09 -0500 Received: by mail-wi0-f178.google.com with SMTP id bz8so3433644wib.17 for ; Fri, 20 Dec 2013 02:14:08 -0800 (PST) Date: Fri, 20 Dec 2013 11:14:05 +0100 From: Stefan Hajnoczi Message-ID: <20131220101405.GE27021@stefanha-thinkpad.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [RFC PATCH v3 3/6] block/raw-posix: implement bdrv_preallocate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: Kevin Wolf , Peter Lieven , Fam Zheng , qemu-devel@nongnu.org On Thu, Dec 19, 2013 at 10:27:38AM +0800, Hu Tao wrote: > +static int raw_preallocate2(int fd, int64_t offset, int64_t length) > +{ > + int ret = -1; > + > + ret = fallocate(fd, 0, offset, length); > + > + /* fallback to posix_fallocate() if fallocate() is not supported */ > + if (ret < 0 && (errno == ENOSYS || errno == EOPNOTSUPP)) { > + ret = posix_fallocate(fd, offset, length); > + } > + > + return ret; Return value semantics differ between the two functions: * fallocate - return 0 or -1 with errno set * posix_fallocate - return 0 or error number (without using errno!) Please make it consistent. Usually in QEMU we return 0 on success and -errno on failure.