From patchwork Tue Sep 15 13:48:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuriy Kolerov X-Patchwork-Id: 517873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id A05DD140134 for ; Tue, 15 Sep 2015 23:48:56 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 72E51319B6; Tue, 15 Sep 2015 13:48:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GxAZ6MRJb-6A; Tue, 15 Sep 2015 13:48:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id CE97C317F2; Tue, 15 Sep 2015 13:48:53 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 2C9AB1C105D for ; Tue, 15 Sep 2015 13:48:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 26C508F998 for ; Tue, 15 Sep 2015 13:48:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZmwzOA3uL-yq for ; Tue, 15 Sep 2015 13:48:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.synopsys.com (us01smtprelay-2.synopsys.com [198.182.47.9]) by whitealder.osuosl.org (Postfix) with ESMTPS id 956438F946 for ; Tue, 15 Sep 2015 13:48:51 +0000 (UTC) Received: from us02secmta2.synopsys.com (us02secmta2.synopsys.com [10.12.235.98]) by smtprelay.synopsys.com (Postfix) with ESMTP id 4727F24E1516 for ; Tue, 15 Sep 2015 06:48:51 -0700 (PDT) Received: from us02secmta2.internal.synopsys.com (us02secmta2.internal.synopsys.com [127.0.0.1]) by us02secmta2.internal.synopsys.com (Service) with ESMTP id 3AB2155F16 for ; Tue, 15 Sep 2015 06:48:51 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by us02secmta2.internal.synopsys.com (Service) with ESMTP id 1C4FC55F15 for ; Tue, 15 Sep 2015 06:48:51 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 030B417C; Tue, 15 Sep 2015 06:48:51 -0700 (PDT) Received: from ykolerov-lab.internal.synopsys.com (ykolerov-lab.internal.synopsys.com [10.121.8.82]) by mailhost.synopsys.com (Postfix) with ESMTP id 3DB59175; Tue, 15 Sep 2015 06:48:49 -0700 (PDT) From: Yuriy Kolerov To: uclibc@uclibc.org, Vineet.Gupta1@synopsys.com, Alexey.Brodkin@synopsys.com, Anton.Kolesov@synopsys.com Subject: [PATCH 1/2] libc: fix setting return value and errno in fallocate() Date: Tue, 15 Sep 2015 16:48:44 +0300 Message-Id: <1442324925-29609-1-git-send-email-yuriy.kolerov@synopsys.com> X-Mailer: git-send-email 2.2.0 Cc: Francois.Bedard@synopsys.com X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" Signed-off-by: Yuriy Kolerov --- libc/sysdeps/linux/common/fallocate.c | 13 ++++++++----- libc/sysdeps/linux/common/fallocate64.c | 11 +++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/libc/sysdeps/linux/common/fallocate.c b/libc/sysdeps/linux/common/fallocate.c index b231226..97ac303 100644 --- a/libc/sysdeps/linux/common/fallocate.c +++ b/libc/sysdeps/linux/common/fallocate.c @@ -12,6 +12,7 @@ #include #include #include +#include #if defined __NR_fallocate extern __typeof(fallocate) __libc_fallocate attribute_hidden; @@ -26,17 +27,19 @@ int attribute_hidden __libc_fallocate(int fd, int mode, __off_t offset, __off_t uint32_t zero = 0; INTERNAL_SYSCALL_DECL(err); ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, mode, - __LONG_LONG_PAIR (zero, off_low), - __LONG_LONG_PAIR (zero, len_low))); + __LONG_LONG_PAIR(zero, off_low), + __LONG_LONG_PAIR(zero, len_low))); # elif __WORDSIZE == 64 INTERNAL_SYSCALL_DECL(err); ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, mode, offset, len)); # else # error your machine is neither 32 bit or 64 bit ... it must be magical # endif - if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) - return INTERNAL_SYSCALL_ERRNO (ret, err); - return 0; + if (unlikely(INTERNAL_SYSCALL_ERROR_P(ret, err))) { + __set_errno(INTERNAL_SYSCALL_ERRNO(ret, err)); + ret = -1; + } + return ret; } # if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU diff --git a/libc/sysdeps/linux/common/fallocate64.c b/libc/sysdeps/linux/common/fallocate64.c index cf75693..d051d37 100644 --- a/libc/sysdeps/linux/common/fallocate64.c +++ b/libc/sysdeps/linux/common/fallocate64.c @@ -13,6 +13,7 @@ #include #include #include +#include #if defined __NR_fallocate @@ -26,10 +27,12 @@ int attribute_hidden __libc_fallocate64(int fd, int mode, __off64_t offset, int ret; INTERNAL_SYSCALL_DECL(err); ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, mode, - OFF64_HI_LO (offset), OFF64_HI_LO (len))); - if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) - return INTERNAL_SYSCALL_ERRNO (ret, err); - return 0; + OFF64_HI_LO(offset), OFF64_HI_LO(len))); + if (unlikely(INTERNAL_SYSCALL_ERROR_P(ret, err))) { + __set_errno(INTERNAL_SYSCALL_ERRNO(ret, err)); + ret = -1; + } + return ret; } # if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU