From patchwork Mon Apr 16 07:33:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 898489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=c-sky.com Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Pg9L50kMz9s0b for ; Mon, 16 Apr 2018 17:33:39 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id B6C9110117; Mon, 16 Apr 2018 09:33:35 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from smtp2200-217.mail.aliyun.com (smtp2200-217.mail.aliyun.com [121.197.200.217]) by helium.openadk.org (Postfix) with ESMTPS id 327DA10117 for ; Mon, 16 Apr 2018 09:33:32 +0200 (CEST) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07031458|-1; CH=green; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03306; MF=ren_guo@c-sky.com; NM=1; PH=DS; RN=2; RT=2; SR=0; TI=SMTPD_---.BiIEmZB_1523864006; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:SMTPD_---.BiIEmZB_1523864006) by smtp.aliyun-inc.com(10.147.43.230); Mon, 16 Apr 2018 15:33:27 +0800 From: Guo Ren To: devel@uclibc-ng.org, ren_guo@c-sky.com Date: Mon, 16 Apr 2018 15:33:25 +0800 Message-Id: <1523864005-8718-1-git-send-email-ren_guo@c-sky.com> X-Mailer: git-send-email 2.7.4 Subject: [uclibc-ng-devel] [PATCH v2] common/sendfile.c: bugfix can't support offset is NULL X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" In ltp testcase sendfile08.c, it use offset=NULL to test the api. PATCH V2: fixup the stupid missing check in the end. Sorry for lose test. See "man sendfile" and it really support offset is NULL. Signed-off-by: Guo Ren --- libc/sysdeps/linux/common/sendfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/sysdeps/linux/common/sendfile.c b/libc/sysdeps/linux/common/sendfile.c index af05ba4..f0372c1 100644 --- a/libc/sysdeps/linux/common/sendfile.c +++ b/libc/sysdeps/linux/common/sendfile.c @@ -40,7 +40,7 @@ ssize_t sendfile(int out_fd, int in_fd, __off_t *offset, size_t count) return -1; } - if (offset == NULL || (int)offset < 0) { + if ((int)offset < 0) { __set_errno(EFAULT); return -1; } @@ -54,7 +54,7 @@ ssize_t sendfile(int out_fd, int in_fd, __off_t *offset, size_t count) res = INLINE_SYSCALL(sendfile64, 4, out_fd, in_fd, off, count); - if (res >= 0) + if (res >= 0 && offset != NULL) *offset = off64; return res;