From patchwork Tue Sep 15 13:48:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuriy Kolerov X-Patchwork-Id: 517874 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 C951D140134 for ; Tue, 15 Sep 2015 23:49:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 50C5031A4C; Tue, 15 Sep 2015 13:49:00 +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 E4lMh7VIgfdG; Tue, 15 Sep 2015 13:48:56 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 12C5F31914; Tue, 15 Sep 2015 13:48:55 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 9E2031C105D for ; Tue, 15 Sep 2015 13:48:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 9B19195D75 for ; Tue, 15 Sep 2015 13:48:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Db3Vrc0UYjLo for ; Tue, 15 Sep 2015 13:48:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.synopsys.com (smtprelay2.synopsys.com [198.182.60.111]) by hemlock.osuosl.org (Postfix) with ESMTPS id 751C495D64 for ; Tue, 15 Sep 2015 13:48:53 +0000 (UTC) Received: from us02secmta2.synopsys.com (us02secmta2.synopsys.com [10.12.235.98]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2E71210C0CD0 for ; Tue, 15 Sep 2015 06:48:53 -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 21A1C55F16 for ; Tue, 15 Sep 2015 06:48:53 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by us02secmta2.internal.synopsys.com (Service) with ESMTP id 064CC55F15 for ; Tue, 15 Sep 2015 06:48:53 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id E2996184; Tue, 15 Sep 2015 06:48:52 -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 540BC182; Tue, 15 Sep 2015 06:48:51 -0700 (PDT) From: Yuriy Kolerov To: uclibc@uclibc.org, Vineet.Gupta1@synopsys.com, Alexey.Brodkin@synopsys.com, Anton.Kolesov@synopsys.com Subject: [PATCH 2/2] libc: fix sign extension in fallocate() Date: Tue, 15 Sep 2015 16:48:45 +0300 Message-Id: <1442324925-29609-2-git-send-email-yuriy.kolerov@synopsys.com> X-Mailer: git-send-email 2.2.0 In-Reply-To: <1442324925-29609-1-git-send-email-yuriy.kolerov@synopsys.com> References: <1442324925-29609-1-git-send-email-yuriy.kolerov@synopsys.com> 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 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libc/sysdeps/linux/common/fallocate.c b/libc/sysdeps/linux/common/fallocate.c index 97ac303..d953a46 100644 --- a/libc/sysdeps/linux/common/fallocate.c +++ b/libc/sysdeps/linux/common/fallocate.c @@ -21,14 +21,12 @@ int attribute_hidden __libc_fallocate(int fd, int mode, __off_t offset, __off_t int ret; # if __WORDSIZE == 32 - uint32_t off_low = offset; - uint32_t len_low = len; - /* may assert that these >>31 are 0 */ - uint32_t zero = 0; + int32_t offset_sign_extension = (offset < 0) ? 0xFFFFFFFF : 0; + int32_t len_sign_extension = (len < 0) ? 0xFFFFFFFF : 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(offset_sign_extension, offset), + __LONG_LONG_PAIR(len_sign_extension, len))); # elif __WORDSIZE == 64 INTERNAL_SYSCALL_DECL(err); ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, mode, offset, len));