From patchwork Thu Oct 29 13:42:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 40919 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 160143854834; Thu, 29 Oct 2020 13:42:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 160143854834 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1603978949; bh=1m9RdrkV/XMaXPplxU/cDwehV/41DxDWVqQGV0at6mc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gFSG349pCCYleOha3yEtuHxksjGxxdq3mFcFQWyD9/SXYXSpqyqmbIEhJM56qLG6N 0ooe74Ybp3Q5DMcPHUjsCGtWCE0CW0z2fKbKpPI4FYzLsG6bWlZUooBqlr91bCNzzW sXAeG6eOD8yONdR63nZUqRATw4d6h5fsjNBx4DEU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 4C2553854834 for ; Thu, 29 Oct 2020 13:42:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4C2553854834 Received: by mail-wr1-x443.google.com with SMTP id s9so2805354wro.8 for ; Thu, 29 Oct 2020 06:42:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1m9RdrkV/XMaXPplxU/cDwehV/41DxDWVqQGV0at6mc=; b=NArhLmokPgsAe+AXEfIHiHsPrH0PMK8VX/v3cnAaW9Uvb0RCeabe/X0ZG7OvQ1ROBK aH6jK5wiluUyOQdGZzROn685W0btqnaH8wJrwPy+DsEEq1inlu6lAvxrMR/5I6615Dz6 9zdkdJB5Lmwx3nHIVEOiVLscQSxRNrfcjU/EFLZbtTq8BkJDy9uRodRWH+Nx4vN8A30Y Go9S/di8o0C8mEJVt2APCwenP+xeIVwkLBwFCJ6t3s6YgE7Bx6ZZHhI7mbppX6bCzhUU 8Y0CdqMWxxCdzlcXC2HUojZX+hx5JIBFlJJusYZjXNYtaaJyUux7BhPENjiugSD3WKUc I2bA== X-Gm-Message-State: AOAM530SPRbDGQaH7JbQcLCXcQh4VbTHbSuq7gFYRm2GotEO65zhQB/0 E9aq9BxbKPFg30o/wKOnh7WJV1G1ncc= X-Google-Smtp-Source: ABdhPJxukwTn1a0aCVQhArgKwMSZ/Ly647l/BY4IhoGYXWvH2sk7r221/e104o3eQ5O13uvHFD7g9g== X-Received: by 2002:a5d:4d0c:: with SMTP id z12mr6273888wrt.60.1603978945397; Thu, 29 Oct 2020 06:42:25 -0700 (PDT) Received: from localhost.localdomain ([170.253.60.68]) by smtp.googlemail.com with ESMTPSA id j13sm5360115wru.86.2020.10.29.06.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 06:42:24 -0700 (PDT) To: mtk.manpages@gmail.com Subject: [PATCH v2] getdents.2: Use appropriate types Date: Thu, 29 Oct 2020 14:42:11 +0100 Message-Id: <20201029134210.191970-1-colomar.6.4.3@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <1195fda6-4de3-09fc-8653-42655d7e2b76@gmail.com> References: <1195fda6-4de3-09fc-8653-42655d7e2b76@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Cc: Alejandro Colomar , linux-man@vger.kernel.org, libc-alpha@sourceware.org, linux-kernel@vger.kernel.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" getdents(): This function has no glibc wrapper. As such, we should use the same types the Linux kernel uses: Use 'long' as the return type. getdents64(): The glibc wrapper uses ssize_t for the return type, and 'size_t' for the count argument. Signed-off-by: Alejandro Colomar --- man2/getdents.2 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/man2/getdents.2 b/man2/getdents.2 index a187fbcef..e14627e6e 100644 --- a/man2/getdents.2 +++ b/man2/getdents.2 @@ -33,14 +33,14 @@ getdents, getdents64 \- get directory entries .SH SYNOPSIS .nf -.BI "int getdents(unsigned int " fd ", struct linux_dirent *" dirp , +.BI "long getdents(unsigned int " fd ", struct linux_dirent *" dirp , .BI " unsigned int " count ); .PP .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .B #include .PP -.BI "int getdents64(unsigned int " fd ", struct linux_dirent64 *" dirp , -.BI " unsigned int " count ); +.BI "ssize_t getdents64(unsigned int " fd ", struct linux_dirent64 *" dirp , +.BI " size_t " count ); .fi .PP .IR Note : @@ -282,7 +282,8 @@ struct linux_dirent { int main(int argc, char *argv[]) { - int fd, nread; + int fd; + long nread; char buf[BUF_SIZE]; struct linux_dirent *d; char d_type; @@ -301,7 +302,7 @@ main(int argc, char *argv[]) printf("\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- nread=%d \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\en", nread); printf("inode# file type d_reclen d_off d_name\en"); - for (int bpos = 0; bpos < nread;) { + for (long bpos = 0; bpos < nread;) { d = (struct linux_dirent *) (buf + bpos); printf("%8ld ", d\->d_ino); d_type = *(buf + bpos + d\->d_reclen \- 1);